Skip to main content

Referral System Overview

Sparky's Referral & Rebate system pays referrers a share of the trading fees generated by the traders they invite. Referrers create a code, traders bind it, and every fill by a bound trader accrues a commission for the referrer.

All paths below are relative to https://api-avax.<sparky-domain>/api/v1 (one deployment per chain — see Base URLs).

How it works

Referrer
├── POST /referral/codes → creates an 8-char code (once per account)
└── shares the code

Trader (referee)
├── POST /referral/bind → binds to the code (can rebind / unbind)
└── every fill: fee × referrer tier rate → referrer's pending earnings

Two ways to collect

Off-chain claimOn-chain claim
EndpointPOST /referral/claimPOST /referral/on-chain/claim-signature + ReferralRebate.claimRebate()
DestinationPlatform available balance (tradeable / withdrawable)USDT in your wallet on-chain
SpeedInstantOne block after the contract call
Minimum10 USDT> 0
GasNoneYou pay chain gas

Accrued rebates are synced to the ReferralRebate contract hourly (batchSyncRebates, operator-signed); the on-chain claim path uses a backend EIP-712 signature with a 1-hour deadline and a per-user nonce read from the contract.

Tier system

Tier is recomputed by the backend on every referee fill from two conditions that must both hold (AND):

LevelNameCommissionBPS≥ referrals≥ cumulative referee volume
0Starter10 %10001$1,000
1Bronze12 %12005$10,000
2Silver17 %170020$100,000
3Gold22 %220050$500,000
4Diamond25 %2500100$2,000,000

Below the Starter threshold GET /referral/dashboard returns tier: null plus a tier_note, and no commission accrues.

commission = referee_trade_fee × tier_rate

Contracts

ContractRole
ReferralStorageCode registry, referral relationships, tier configuration (read-only from the backend)
ReferralRebateAccrued rebate ledger, claim-signature verification, nonce management, batchSyncRebates

Addresses are per chain; read contract_address from GET /referral/on-chain/operator-status.

Authentication

Protected endpoints require a JWT. Write operations additionally require an EIP-712 signature from the wallet (the same domain as the login typed data — fetch it from GET /auth/nonce/{address}):

OperationType string
Create codeCreateReferralCode(address wallet,uint256 timestamp)
Bind codeBindReferralCode(address wallet,string code,uint256 timestamp)
Unbind codeUnbindReferralCode(address wallet,uint256 timestamp)

timestamp is Unix seconds and must be within ±5 minutes of server time (TIMESTAMP_EXPIRED).

Endpoints

Public

MethodEndpointDescription
GET/referral/leaderboardTop-N referrers by commission
GET/referral/on-chain/user-rebate/:addressOn-chain rebate state
GET/referral/on-chain/referral-info/:addressOn-chain referral config (BPS)
GET/referral/on-chain/claimed/:addressOn-chain claimed total
GET/referral/on-chain/operator-statusBackend signer / operator status + contract address

Protected (JWT)

MethodEndpointDescription
GET/referral/statusStatus as referrer and referee
POST/referral/codesCreate referral code
POST/referral/bindBind / rebind a code
POST/referral/unbindUnbind
GET/referral/dashboardEarnings dashboard
GET/referral/logsOperation history
POST/referral/claimOff-chain claim
POST/referral/on-chain/claim-signatureOn-chain claim signature

Error codes

Errors use { "error": "...", "code": "..." }.

codeHTTPMeaning
TIMESTAMP_EXPIRED400Signature timestamp outside ±5 min
INVALID_SIGNATURE_FORMAT400Not a 0x hex signature
SIGNATURE_INVALID401Recovered address ≠ JWT address
CODE_ALREADY_EXISTS409Account already has a code
CODE_NOT_FOUND404Unknown code
SELF_REFERRAL400Binding your own code
SAME_REFERRER400Already bound to this referrer
NOT_BOUND400Unbind with no binding
NO_PENDING_EARNINGS400Nothing to claim
BELOW_MINIMUM400Pending < 10 USDT
INVALID_AMOUNT400Claim amount malformed or ≤ 0
INVALID_ADDRESS400Address malformed
INVALID_PARAM400Leaderboard n outside 1–50
CHAIN_ERROR500Contract read failed
SIGNATURE_ERROR500Backend could not sign
CONFIG_ERROR500Signer key not configured
DB_ERROR, CREATE_FAILED, BIND_FAILED, UNBIND_FAILED, TX_FAILED, TX_COMMIT_FAILED500Server errors