- {statCards.map(card => (
-
-
{card.value}
-
{card.label}
+ )}
+
+ {isConnected && affiliateAddress && (
+ <>
+ {affiliateConfig && (
+
+
+ BPS
+
+ {affiliateConfig.bps} ({(affiliateConfig.bps / 100).toFixed(2)}%)
+
+
+ {affiliateConfig.partnerCode && (
+
+ Code
+ {affiliateConfig.partnerCode}
+
+ )}
+
+ Status
+
+ {affiliateConfig.isActive ? 'Active' : 'Inactive'}
+
+
- ))}
-
- ) : null}
+ )}
- {!stats && !error && !isLoading ? (
-
-
- Enter an affiliate address above to view performance stats.
-
-
- ) : null}
+
+ {tabs.map(tab => (
+
+ ))}
+
+
+ {activeTab === 'overview' && (
+ <>
+
+ {periods.map((period, i) => (
+
+ ))}
+
+
+ {statsError ?
{statsError}
: null}
+
+ {isLoading && !stats && (
+
+ )}
+
+ {statCards && (
+
+ {statCards.map(card => (
+
+
{card.value}
+
{card.label}
+
+ ))}
+
+ )}
+
+ {!stats && !statsError && !isLoading && (
+
+
No affiliate stats found for this address.
+
+ )}
+ >
+ )}
+
+ {activeTab === 'swaps' && (
+ <>
+
+ {periods.map((period, i) => (
+
+ ))}
+
+
+ {swapsError ?
{swapsError}
: null}
+
+ {swapsLoading && (
+
+ )}
+
+ {!swapsLoading && swaps.length === 0 && !swapsError && (
+
+
No swaps found for this period.
+
+ )}
+
+ {swaps.length > 0 && (
+ <>
+
+
+
+
+ | Date |
+ Sell |
+ Buy |
+ Volume |
+ Fee |
+ BPS |
+ Status |
+
+
+
+ {swaps.map((swap: AffiliateSwap) => (
+
+ | {formatDate(swap.createdAt)} |
+
+
+ {typeof swap.sellAsset === 'object'
+ ? swap.sellAsset.symbol ?? 'Unknown'
+ : swap.sellAsset}
+
+ |
+
+
+ {typeof swap.buyAsset === 'object'
+ ? swap.buyAsset.symbol ?? 'Unknown'
+ : swap.buyAsset}
+
+ |
+
+ {formatUsd(parseFloat(swap.sellAmountUsd) || 0)}
+ |
+
+ {formatUsd(parseFloat(swap.affiliateFeeUsd) || 0)}
+ |
+
+ {Math.max(0, parseInt(String(swap.affiliateBps ?? '0'), 10) - 10)}
+ |
+
+
+ {swap.status}
+
+ |
+
+ ))}
+
+
+
+
+ {totalSwapPages > 1 && (
+
+
+
+ Page {swapPage + 1} of {totalSwapPages}
+
+
+
+ )}
+ >
+ )}
+ >
+ )}
+
+ {activeTab === 'settings' && (
+
+ {actionMessage && (
+
+ {actionMessage.text}
+
+
+ )}
+
+ {!isAuthenticated && (
+
+
+
+
Sign in to manage settings
+
+ Sign a message with your wallet to prove ownership. This does not cost
+ gas.
+
+ {authError &&
{authError}
}
+
+
+
+
+ )}
+
+ {isAuthenticated && (
+
+ Authenticated
+
+
+ )}
+
+ {!affiliateConfig && isAuthenticated && (
+
+
Register as Affiliate
+
+ Register your connected wallet to start earning fees on swaps.
+
+
+
+ {shortenAddress(affiliateAddress)}
+
+
+
+ setRegisterBps(e.target.value)}
+ placeholder='BPS (e.g. 30)'
+ style={{ ...styles.formInput, maxWidth: 120 }}
+ min={0}
+ max={1000}
+ />
+
+ {(parseInt(registerBps, 10) / 100 || 0).toFixed(2)}%
+
+
+
+
+ )}
+
+ {affiliateConfig && (
+ <>
+
+
Current Configuration
+
+ Wallet
+
+ {shortenAddress(affiliateConfig.walletAddress)}
+
+
+
+ Receive Address
+
+ {shortenAddress(
+ affiliateConfig.receiveAddress ?? affiliateConfig.walletAddress,
+ )}
+
+
+
+ BPS
+
+ {affiliateConfig.bps} ({(affiliateConfig.bps / 100).toFixed(2)}%)
+
+
+
+ Partner Code
+
+ {affiliateConfig.partnerCode ?? 'None'}
+
+
+
+ Status
+
+ {affiliateConfig.isActive ? 'Active' : 'Inactive'}
+
+
+
+ Created
+
+ {formatDate(affiliateConfig.createdAt)}
+
+
+
+
+ {isAuthenticated && !affiliateConfig.partnerCode && (
+
+
Claim Partner Code
+
+ Claim a unique partner code for your affiliate link.
+
+
+ setClaimCode(e.target.value)}
+ placeholder='Enter partner code'
+ style={styles.formInput}
+ spellCheck={false}
+ />
+
+
+
+ )}
+
+ {isAuthenticated && (
+
+
Update BPS
+
+ Change your affiliate fee basis points (1 BPS = 0.01%).
+
+
+ setUpdateBps(e.target.value)}
+ placeholder={String(affiliateConfig.bps)}
+ style={{ ...styles.formInput, maxWidth: 120 }}
+ min={0}
+ max={1000}
+ />
+ {updateBps && (
+
+ {(parseInt(updateBps, 10) / 100 || 0).toFixed(2)}%
+
+ )}
+
+
+
+ )}
+
+ {isAuthenticated && (
+
+
Receive Address
+
+ The address where affiliate revenue will be sent. Defaults to your
+ connected wallet. Useful for multisigs, treasuries, or cold wallets.
+
+
+ Current
+
+ {affiliateConfig.receiveAddress
+ ? shortenAddress(affiliateConfig.receiveAddress)
+ : `${shortenAddress(affiliateConfig.walletAddress)} (wallet)`}
+
+
+
+ setUpdateReceiveAddress(e.target.value)}
+ placeholder='0x...'
+ style={styles.formInput}
+ spellCheck={false}
+ />
+
+
+
+ )}
+ >
+ )}
+
+ )}
+ >
+ )}