Skip to main content

Referral System Overview

The ZTDX Referral & Rebate system allows users to earn commissions by inviting traders to the platform. Referrers create unique invitation codes, share them with traders, and earn a percentage of the trading fees generated by their referees.

Base URL: https://api.prex.world/api/v1

How It Works

Referrer (Promoter)
├── Creates referral code (POST /referral/codes)
└── Shares code with traders

Trader (Referee)
├── Binds referral code (POST /referral/bind)
└── Every trade generates fees → Referrer earns commission

Commission Flow

Trader executes a trade
→ Backend calculates commission (trade_fee × tier_rate)
→ Recorded in referral_earnings (chain_sync_status = 'pending')
→ Batch synced to the on-chain contract every 5 minutes (batchSettleRewards)
→ chain_sync_status = 'synced'

Referrer claims on-chain:
POST /referral/claim
→ Creates a claim order over all synced, unclaimed earnings
→ Returns an EIP-712 signature
Referrer calls redeemReward(amount, deadline, signature) on the contract
→ Backend observes RewardRedeemed → earnings marked 'claimed', claim order 'success'

Tier System

Commission rates are determined by the referrer's tier, which is based on the cumulative trading volume of their referees:

LevelTier NameCommission RateBPSMin Referrals (AND)Min Referred Volume (AND)
0Starter10%1000— (default floor)— (default floor)
1Bronze12%1200≥ 5≥ $10,000
2Silver17%1700≥ 20≥ $100,000
3Gold22%2200≥ 50≥ $500,000
4Diamond25%2500≥ 100≥ $2,000,000

Every user is at least Starter (10%) with no threshold — the Starter tier is a floor that applies from day one. Promotion to a higher tier requires BOTH the referral-count and the referred-volume conditions to be met simultaneously. The rate is recomputed live from the referrer's current referral count and referred volume on each request/accrual.

Smart Contracts

On-chain settlement is handled by a single RewardRouter-style contract, ZtdxRewardRouter (configured via REFERRAL_REBATE_ADDRESS):

MethodPurpose
rewardAccountInfo(address)Per-user rebate account: redeemed amount, nonce, code, affiliate, tier level
affiliateRewardInfo(address)Trader's referral config: code, affiliate, total/discount/reward BPS
redeemedRewards(address)Cumulative redeemed reward amount
redeemReward(amount, deadline, signature)User-facing claim with a backend EIP-712 signature
batchSettleRewards(users, amounts, batchId)Backend batch sync of accrued commission (every 5 minutes)

A companion AffiliateRegistry storage contract (REFERRAL_STORAGE_ADDRESS) holds referral-code mappings and tier settings.

The ZtdxRewardRouter address can be obtained via GET /referral/on-chain/operator-status (contract_address field).

Authentication

All protected endpoints require a JWT Bearer token:

Authorization: Bearer <token>

Token is obtained through the EIP-712 login flow. See Authentication for details.

API Endpoints

Public Endpoints (No Auth Required)

MethodEndpointDescription
GET/referral/leaderboardTop-N referral commission leaderboard
GET/referral/on-chain/user-rebate/:addressQuery user's on-chain rebate info
GET/referral/on-chain/referral-info/:addressQuery trader's on-chain referral config
GET/referral/on-chain/claimed/:addressQuery on-chain claimed amount
GET/referral/on-chain/operator-statusCheck backend signer operator status

Protected Endpoints (JWT Required)

MethodEndpointDescription
POST/referral/codesCreate referral code
POST/referral/bindBind to a referral code
POST/referral/unbindUnbind from referral code
GET/referral/statusQuery referral status (as referrer & referee)
GET/referral/dashboardGet referral center dashboard (V2)
GET/referral/logsQuery operation history
POST/referral/claimCreate commission claim + get on-chain redeem signature
POST/referral/on-chain/claim-signatureGenerate on-chain claim signature (custom amount)
GET/referral/tradersList directly bound traders with volume/commission aggregates
GET/referral/affiliatesList downline affiliates with spread commission aggregates
POST/referral/affiliatesPromote a direct trader to affiliate with a sub-rate
PUT/referral/affiliates/:walletUpdate an affiliate's sub-rate
GET/referral/claims/previewPreview claimable / pending commission
GET/referral/claimsList my commission claim orders

See Rebate Records for detailed request/response documentation of the traders, affiliates, and claims endpoints.

EIP-712 Signature Types

OperationTypeHash
Create CodeCreateReferralCode(address wallet,uint256 timestamp)
Bind CodeBindReferralCode(address wallet,string code,uint256 timestamp)
Unbind CodeCreateReferralCode(address wallet,uint256 timestamp) — unbind reuses the create-code struct; there is no separate UnbindReferralCode type

EIP-712 Domain can be obtained from GET /auth/nonce/:addresstyped_data.domain.