Skip to main content

Overview

Kuest allows you to configure platform trading fees, affiliate commission sharing, and fee recipient addresses. Fees are charged on-chain during trade execution and can be customized per deployment.

Trading Fees

Trading fees are charged as a percentage of each trade and split between the platform and affiliates.

Fee Structure

Total Trading Fee = Base Fee + Platform Fee
  • Exchange Base Fee: On-chain minimum (e.g., 0.20%)
  • Platform Fee: Your custom addition (configurable)
  • Total Fee: What users pay per trade
Distribution:
  • Platform Share: Percentage kept by platform
  • Affiliate Share: Percentage paid to referrers
Example with 2% total fee:
  • User trades $100
  • Trading fee: $2.00 (2%)
  • Affiliate gets: $1.00 (50% of fee)
  • Platform keeps: $1.00 (50% of fee)

Configuring Trading Fees

  1. Navigate to AdminFees
  2. Find Trading Fees section
  3. Set Trading fee (%) (minimum enforced)
  4. Set Affiliate share (%) (0-100%)
  5. Click Save settings
The system will display the minimum fee based on the on-chain base fee rate. You cannot set a fee below this minimum.

Fee Validation

The system validates fees to ensure they meet on-chain requirements:
src/app/[locale]/admin/affiliate/_actions/update-affiliate-settings.ts
const tradeFeeBps = Math.round(parsed.data.trade_fee_percent * 100)
const exchangeBaseFeeBps = await fetchMaxExchangeBaseFeeRate()

if (exchangeBaseFeeBps !== null && tradeFeeBps < exchangeBaseFeeBps) {
  return { 
    error: `Trading fee must be at least ${(exchangeBaseFeeBps / 100).toFixed(2)}%.` 
  }
}
Attempting to set a trading fee below the on-chain base fee will result in an error. The minimum is typically 0.20% but can vary by network.

Fee Recipient Wallet

Configure the Polygon wallet address that receives platform trading fees.
  1. Navigate to AdminGeneral
  2. Scroll to Market and fee settings
  3. Enter your Polygon wallet address in Fee recipient wallet
  4. Format: 0xabc123... (42-character hex address)
  5. Click Save settings
If left empty, the zero address (0x0000...0000) is used and fees are effectively burned.
Important: Ensure you control this wallet address. Once fees are sent to this address, they cannot be redirected without updating the settings.

Affiliate Configuration

Affiliate Share

Control how much of the trading fee is shared with affiliates:
  • Value: 0-100% of the trading fee
  • Location: Admin → Fees → Affiliate share (%)
  • Default: Configurable
Example:
  • Trading fee: 2%
  • Affiliate share: 50%
  • On a $100 trade:
    • Total fee: $2.00
    • Affiliate receives: 1.00(501.00 (50% of 2.00)
    • Platform receives: $1.00 (remaining 50%)

Referral System

The affiliate system tracks referrals on-chain via the exchange contract:
src/lib/exchange.ts
export async function fetchReferralLocked(
  exchange: `0x${string}`,
  maker: `0x${string}`,
): Promise<boolean | null> {
  const result = await getExchangeClient().readContract({
    address: exchange,
    abi: exchangeReferralAbi,
    functionName: 'referrals',
    args: [maker],
  })
  
  // Returns: [referrer, affiliate, affiliatePercentage, locked]
  return result[3] // locked status
}

Fee Data API

Fee totals are tracked and can be queried:
src/lib/data-api/fees.ts
export async function fetchFeeReceiverTotals({
  endpoint,
  address,
  exchange,
  tokenId,
  limit = 100,
  offset = 0,
}: FeeReceiverTotalsParams): Promise<FeeReceiverTotal[]>

export function sumFeeTotals(totals: FeeReceiverTotal[]): bigint

export function sumFeeVolumes(totals: FeeReceiverTotal[]): bigint

Market Creators

Control which wallet addresses can create markets that appear on your fork.
  1. Navigate to AdminGeneral
  2. Find Market and fee settings
  3. Enter wallet addresses in Allowed market creator wallets
  4. Format: One address per line
  5. Example:
    0xabc123...
    0xdef456...
    0x789abc...
    
  6. Click Save settings
Market creator filtering is useful for:
  • Private prediction markets
  • Whitelabel deployments
  • Testing and development
  • Niche market categories

Settings Storage

Fee-related settings are stored in the database:
GroupKeyDescriptionExample
affiliatetrade_fee_bpsTrading fee in basis points200 (2%)
affiliateaffiliate_share_bpsAffiliate share in basis points5000 (50%)
generalfee_recipient_walletPlatform fee wallet address0xabc...
generalmarket_creatorsAllowed creator addresses (newline-separated)0xabc...\n0xdef...
Basis points (bps) are 1/100th of a percent. 100 bps = 1%. This is used internally for precision.

Accessing Fee Settings

import { fetchAffiliateSettingsFromAPI } from '@/lib/affiliate-data'

const result = await fetchAffiliateSettingsFromAPI()

if (result.success) {
  const settings = result.data
  console.log(settings.tradeFeePercent)        // "2.00"
  console.log(settings.affiliateSharePercent)  // "50.00"
  console.log(settings.platformSharePercent)   // "50.00"
  console.log(settings.tradeFeeDecimal)        // 0.02
}

Fee Calculation Example

Let’s walk through a complete fee calculation:
1

User places trade

  • Trade amount: $500
  • Trading fee: 2% (0.02)
  • Affiliate share: 40%
2

Calculate total fee

const tradingFee = 500 * 0.02 = $10.00
3

Split fee

const affiliateCommission = 10.00 * 0.40 = $4.00
const platformShare = 10.00 * 0.60 = $6.00
4

Distribute on-chain

  • $4.00 → Affiliate address
  • $6.00 → Platform fee recipient wallet
  • User receives: $500 worth of shares (minus fees)

Best Practices

  • Research competitor fee structures
  • Balance revenue with user acquisition
  • Consider volume-based fee tiers (requires custom implementation)
  • Monitor fee impact on trading volume
  • Test different fee levels with A/B testing
  • Set competitive affiliate shares (30-50% is common)
  • Higher shares attract more affiliates
  • Monitor affiliate fraud and abuse
  • Track affiliate performance via admin panel
  • Provide marketing materials for affiliates
  • Use a multi-sig wallet for large deployments
  • Regularly withdraw fees to cold storage
  • Monitor fee recipient balance
  • Set up alerts for large fee accumulations
  • Keep backup of fee recipient private key (securely)
  • Start with a small list of trusted creators
  • Expand gradually as you verify quality
  • Remove creators who violate terms
  • Consider automated creator verification
  • Document creator guidelines clearly

Troubleshooting

Problem: Cannot save trading fee below on-chain minimumSolution:
  • Check the current on-chain base fee rate
  • Set your fee at or above this minimum
  • Contact blockchain team if minimum seems incorrect
  • Verify you’re on the correct network (Polygon, testnet, etc.)
Problem: Trading fees not appearing in recipient walletSolution:
  • Verify fee recipient wallet address is correct
  • Check if address is the zero address (fees are burned)
  • Confirm trades are being executed successfully
  • Check Polygonscan for fee transactions
  • Ensure sufficient gas for fee transfers
Problem: Error when saving wallet addressSolution:
  • Ensure address starts with 0x
  • Verify address is exactly 42 characters
  • Check for typos or invalid characters
  • Copy address directly from wallet app
  • Test address on Polygonscan
Problem: Markets from specified creators not showing upSolution:
  • Verify addresses are formatted correctly (one per line)
  • Check that creators have actually created markets
  • Ensure addresses match exactly (case-insensitive but exact)
  • Look for whitespace or hidden characters
  • Clear cache and restart server

Admin Panel

Access fee configuration interface

Affiliate System

Learn about affiliate tracking

Smart Contracts

Understand on-chain fee mechanisms

Branding

Configure other platform settings

Build docs developers (and LLMs) love