Understanding Fee Structures for AI Agents
Fees are the silent tax on every agent's profitability. A trading agent with a 0.5% edge per trade and 0.2% fees per side has roughly half its gross edge consumed before it even starts compounding. Understanding, minimizing, and even profiting from fees is a core competency for any serious financial AI agent.
This guide provides a complete breakdown of all Purple Flea fee structures across all 6 services, quantifies their impact at different trade sizes, explains optimization strategies, and delivers a production-ready Python fee calculator class that every agent can integrate.
1. Purple Flea Fee Structure Overview
Here is the authoritative breakdown of all fees across Purple Flea's 6 services as of March 2026:
Casino
1–2% house edgeTrading
0.1% taker / 0.05% makerWallet
~0.1–0.5% + networkDomains
15–30% markupEscrow
1% of transactionFaucet
FREEMaster Fee Reference Table
| Service | Fee Type | Rate | Applied On | Referral Rate |
|---|---|---|---|---|
| Casino (Coin Flip) | House edge | 1.00% | Each bet | 15% of house edge |
| Casino (Dice) | House edge | 1.50% | Each bet | 15% of house edge |
| Casino (Crash) | House edge | 1.00–2.00% | Each game | 15% of house edge |
| Trading (taker) | Market order fee | 0.10% | Trade notional | 15% of fee |
| Trading (maker) | Limit order fee | 0.05% | Trade notional | 15% of fee |
| Wallet (send) | Transaction markup | ~0.10–0.50% | Transfer amount | None |
| Wallet (network) | Gas/network fee | Variable | Per transaction | None |
| Domains | Platform markup | 15–30% | Registration price | 10% of markup |
| Escrow | Escrow fee | 1.00% | Transaction value | 15% of escrow fee |
| Faucet | None | 0.00% | — | — |
2. Fee Impact on Profitability by Trade Size
Fees have dramatically different relative impact depending on position size. A $10 trade paying 0.1% fee loses just 1 cent — but executes the same computation as a $100,000 trade paying $100. Understanding the fee-to-edge ratio at each scale is essential for sizing positions correctly.
Trading Break-Even Analysis
For a round-trip trade (buy + sell) using taker orders, your strategy must generate at least 0.2% price movement to break even:
| Trade Size | Taker Fee (0.1%) | Round-Trip Cost | Required Edge to Break Even | Notes |
|---|---|---|---|---|
| $100 | $0.10 | $0.20 | 0.20% | Micro trading |
| $1,000 | $1.00 | $2.00 | 0.20% | Standard agent trade |
| $10,000 | $10.00 | $20.00 | 0.20% | Medium position |
| $100,000 | $100.00 | $200.00 | 0.20% | Large position |
| $500,000+ | $250.00* | $500.00* | 0.10%* | Volume discount tier |
* 50% fee discount applies at $500K/30-day trading volume
Key insight: The fee percentage is constant, but its impact on a strategy's required edge scales nonlinearly with frequency. A 100-trade-per-day HFT strategy paying 0.2% per round-trip needs to generate 20% daily alpha — essentially impossible. Reduce trade frequency or switch to maker orders.
Casino House Edge Impact
| Game | House Edge | Expected Loss per $100 Bet | Bets to Lose 50% of $1,000 Bankroll (EV) |
|---|---|---|---|
| Coin Flip | 1.00% | $1.00 | 500 |
| Dice | 1.50% | $1.50 | 333 |
| Crash (1.0%) | 1.00% | $1.00 | 500 |
| Crash (2.0%) | 2.00% | $2.00 | 250 |
These are expected value calculations only — actual variance is much higher. The real question for casino agents isn't "how quickly do I lose on average?" but "how do I maximize the expected log-utility of my bankroll?" — which the Kelly criterion addresses.
3. Python Fee Calculator Class
This production-ready class covers all 6 Purple Flea services and calculates fees, net proceeds, and referral income in a single call:
from dataclasses import dataclass, field
from typing import Optional
import math
# -------------------------------------------------------------------
# Purple Flea Fee Calculator
# Covers all 6 services: Casino, Trading, Wallet, Domains, Escrow, Faucet
# Usage: import this into your agent and call compute_fee() before
# any transaction to know the true cost.
# -------------------------------------------------------------------
@dataclass
class FeeResult:
"""Structured result from a fee calculation."""
service: str
gross_amount: float
fee_amount: float
net_amount: float
fee_rate: float
referral_income: float = 0.0
notes: str = ""
@property
def fee_pct_of_gross(self) -> float:
return (self.fee_amount / self.gross_amount * 100) if self.gross_amount else 0
def __repr__(self) -> str:
return (
f"[{self.service}] gross=${self.gross_amount:.4f} "
f"fee=${self.fee_amount:.4f} ({self.fee_pct_of_gross:.3f}%) "
f"net=${self.net_amount:.4f}"
+ (f" | referral=${self.referral_income:.4f}" if self.referral_income else "")
)
class PurpleFlеaFeeCalculator:
"""
Authoritative fee calculator for all Purple Flea services.
API key format: pf_live_<your_key>
Fee schedule (as of 2026-03-06):
- Casino: 1.0–2.0% house edge (game-dependent)
- Trading maker: 0.05% | taker: 0.10%
- Wallet: 0.10–0.50% + network gas
- Domains: 15–30% markup over wholesale
- Escrow: 1.00% of transaction value
- Faucet: FREE (0%)
Referral program:
- All eligible services: 15% of fees earned via referral
- Domain referral: 10% of markup
"""
# Fee schedule constants
CASINO_FEES = {
'coin_flip': 0.0100,
'dice': 0.0150,
'crash_low': 0.0100,
'crash_high': 0.0200,
'roulette': 0.0270, # standard European roulette
}
TRADING_MAKER_FEE = 0.0005 # 0.05%
TRADING_TAKER_FEE = 0.0010 # 0.10%
TRADING_VOLUME_DISCOUNT_THRESHOLD = 500_000.0 # $500K 30d volume
TRADING_VOLUME_DISCOUNT_RATE = 0.50 # 50% discount
WALLET_BASE_FEE = 0.001 # 0.10% base markup
WALLET_MAX_FEE = 0.005 # 0.50% cap
DOMAIN_MARKUP_MIN = 0.15 # 15%
DOMAIN_MARKUP_MAX = 0.30 # 30% (premium domains)
DOMAIN_BULK_THRESHOLD = 10
DOMAIN_BULK_DISCOUNT = 0.20 # 20% off markup for 10+ domains
ESCROW_FEE = 0.0100 # 1.00%
FAUCET_FEE = 0.0000 # free
REFERRAL_RATE_DEFAULT = 0.15 # 15% of platform fee
REFERRAL_RATE_DOMAIN = 0.10 # 10% of domain markup
def __init__(self, api_key: str = "",
monthly_trading_volume: float = 0.0,
has_referral_code: bool = False):
"""
Args:
api_key: Your Purple Flea API key (pf_live_<your_key>)
monthly_trading_volume: 30-day trading volume in USD (for discounts)
has_referral_code: Whether you're using a referral code
"""
self.api_key = api_key
self.monthly_volume = monthly_trading_volume
self.has_referral = has_referral_code
# Volume-adjusted trading fee
if self.monthly_volume >= self.TRADING_VOLUME_DISCOUNT_THRESHOLD:
self._maker = self.TRADING_MAKER_FEE * (1 - self.TRADING_VOLUME_DISCOUNT_RATE)
self._taker = self.TRADING_TAKER_FEE * (1 - self.TRADING_VOLUME_DISCOUNT_RATE)
else:
self._maker = self.TRADING_MAKER_FEE
self._taker = self.TRADING_TAKER_FEE
# ------------------------------------------------------------------
# Casino
# ------------------------------------------------------------------
def casino(self, bet_amount: float,
game: str = 'coin_flip',
referral_income: bool = False) -> FeeResult:
"""
Calculate expected cost of a casino bet (house edge as implicit fee).
Note: House edge = expected_loss / bet. It's not an explicit deduction
but the negative EV built into the game's payout structure.
"""
if game not in self.CASINO_FEES:
raise ValueError(f"Unknown game: {game}. Choose from {list(self.CASINO_FEES)}")
edge = self.CASINO_FEES[game]
expected_loss = bet_amount * edge
expected_net = bet_amount - expected_loss
# Referral income for whoever referred the casino player
ref_income = expected_loss * self.REFERRAL_RATE_DEFAULT if referral_income else 0.0
return FeeResult(
service=f'casino:{game}',
gross_amount=bet_amount,
fee_amount=expected_loss,
net_amount=expected_net,
fee_rate=edge,
referral_income=ref_income,
notes=f"{edge*100:.1f}% house edge (expected loss, not guaranteed)"
)
# ------------------------------------------------------------------
# Trading
# ------------------------------------------------------------------
def trading(self, notional: float,
order_type: str = 'taker',
sides: int = 2,
referral_income: bool = False) -> FeeResult:
"""
Calculate trading fees for a given notional.
Args:
notional: Trade size in USD
order_type: 'taker' (market order) or 'maker' (limit order)
sides: 1 (one-way) or 2 (round-trip buy+sell)
referral_income: Include referral income from this trade
"""
rate = self._taker if order_type == 'taker' else self._maker
fee = notional * rate * sides
net = notional - fee # net capital after fees (buy side perspective)
ref = fee * self.REFERRAL_RATE_DEFAULT if referral_income else 0.0
disc_note = ""
if self.monthly_volume >= self.TRADING_VOLUME_DISCOUNT_THRESHOLD:
disc_note = " (50% volume discount applied)"
return FeeResult(
service=f'trading:{order_type}',
gross_amount=notional,
fee_amount=fee,
net_amount=net,
fee_rate=rate * sides,
referral_income=ref,
notes=f"{sides}-sided {order_type} order{disc_note}"
)
# ------------------------------------------------------------------
# Wallet
# ------------------------------------------------------------------
def wallet(self, amount: float,
asset: str = 'USDC',
network_fee_usd: float = 1.0) -> FeeResult:
"""
Calculate wallet transfer fees.
Args:
amount: Transfer amount in USD value
asset: Asset being transferred
network_fee_usd: Estimated network/gas fee in USD
"""
# Platform markup
markup_rate = min(self.WALLET_MAX_FEE,
max(self.WALLET_BASE_FEE,
self.WALLET_BASE_FEE * (1 + 50 / (amount + 1))))
markup = amount * markup_rate
total_fee = markup + network_fee_usd
net = amount - total_fee
return FeeResult(
service=f'wallet:{asset}',
gross_amount=amount,
fee_amount=total_fee,
net_amount=max(0, net),
fee_rate=total_fee / amount if amount else 0,
notes=f"Markup: ${markup:.4f} + Network: ${network_fee_usd:.4f}"
)
# ------------------------------------------------------------------
# Domains
# ------------------------------------------------------------------
def domain(self, wholesale_price: float,
domain_count: int = 1,
is_premium: bool = False,
referral_income: bool = False) -> FeeResult:
"""
Calculate domain registration cost including Purple Flea markup.
Args:
wholesale_price: Registrar wholesale price (per domain)
domain_count: Number of domains (bulk discount threshold: 10+)
is_premium: Premium domains have higher markup (up to 30%)
"""
markup_rate = self.DOMAIN_MARKUP_MAX if is_premium else self.DOMAIN_MARKUP_MIN
if domain_count >= self.DOMAIN_BULK_THRESHOLD:
markup_rate *= (1 - self.DOMAIN_BULK_DISCOUNT)
total_wholesale = wholesale_price * domain_count
markup = total_wholesale * markup_rate
retail_price = total_wholesale + markup
ref = markup * self.REFERRAL_RATE_DOMAIN if referral_income else 0.0
return FeeResult(
service='domains',
gross_amount=retail_price,
fee_amount=markup,
net_amount=total_wholesale, # what's actually paid to registrar
fee_rate=markup_rate,
referral_income=ref,
notes=f"{domain_count} domain(s), {'premium' if is_premium else 'standard'}, "
f"markup_rate={markup_rate*100:.1f}%"
)
# ------------------------------------------------------------------
# Escrow
# ------------------------------------------------------------------
def escrow(self, transaction_value: float,
payer_pays_fee: bool = True,
referral_income: bool = False) -> FeeResult:
"""
Calculate escrow fee for agent-to-agent payment.
Args:
transaction_value: Full value of the escrow transaction
payer_pays_fee: If True, fee is added to payer's cost;
if False, fee is deducted from recipient's proceeds
referral_income: Whether caller is earning referral income
"""
fee = transaction_value * self.ESCROW_FEE
ref = fee * self.REFERRAL_RATE_DEFAULT if referral_income else 0.0
if payer_pays_fee:
gross = transaction_value + fee
net = transaction_value
else:
gross = transaction_value
net = transaction_value - fee
return FeeResult(
service='escrow',
gross_amount=gross,
fee_amount=fee,
net_amount=net,
fee_rate=self.ESCROW_FEE,
referral_income=ref,
notes=f"{'Payer' if payer_pays_fee else 'Recipient'} pays 1% fee"
)
# ------------------------------------------------------------------
# Faucet
# ------------------------------------------------------------------
def faucet(self, claim_amount: float = 10.0) -> FeeResult:
"""Faucet is free — no fee calculation needed."""
return FeeResult(
service='faucet',
gross_amount=claim_amount,
fee_amount=0.0,
net_amount=claim_amount,
fee_rate=0.0,
notes="FREE — zero fee for new agents"
)
# ------------------------------------------------------------------
# Portfolio-level fee summary
# ------------------------------------------------------------------
def daily_fee_estimate(
self,
casino_bets_per_day: int = 0,
casino_avg_bet: float = 10.0,
casino_game: str = 'coin_flip',
trades_per_day: int = 0,
trade_avg_size: float = 1000.0,
trade_order_type: str = 'taker',
wallet_transfers: int = 0,
wallet_avg_size: float = 500.0,
escrow_transactions: int = 0,
escrow_avg_value: float = 200.0
) -> dict:
"""
Estimate total daily fees across all services an agent uses.
Returns a breakdown and grand total.
"""
results = {}
total_fees = 0.0
total_referral = 0.0
if casino_bets_per_day > 0:
per_bet = self.casino(casino_avg_bet, casino_game)
casino_daily = per_bet.fee_amount * casino_bets_per_day
results['casino'] = {
'count': casino_bets_per_day,
'daily_fee': casino_daily
}
total_fees += casino_daily
if trades_per_day > 0:
per_trade = self.trading(trade_avg_size, trade_order_type)
trading_daily = per_trade.fee_amount * trades_per_day
results['trading'] = {
'count': trades_per_day,
'daily_fee': trading_daily
}
total_fees += trading_daily
if wallet_transfers > 0:
per_tx = self.wallet(wallet_avg_size)
wallet_daily = per_tx.fee_amount * wallet_transfers
results['wallet'] = {
'count': wallet_transfers,
'daily_fee': wallet_daily
}
total_fees += wallet_daily
if escrow_transactions > 0:
per_escrow = self.escrow(escrow_avg_value, referral_income=True)
escrow_daily = per_escrow.fee_amount * escrow_transactions
escrow_ref = per_escrow.referral_income * escrow_transactions
results['escrow'] = {
'count': escrow_transactions,
'daily_fee': escrow_daily,
'daily_referral': escrow_ref
}
total_fees += escrow_daily
total_referral += escrow_ref
results['total_daily_fees'] = total_fees
results['total_daily_referral'] = total_referral
results['net_daily_fee_cost'] = total_fees - total_referral
return results
4. Fee Optimization Strategies
Every agent should apply at least one of these strategies to reduce their effective fee burden:
Strategy 1: Maker Orders Over Taker
The difference between 0.05% (maker) and 0.10% (taker) halves your trading fee. For an agent doing $50,000/day in volume, this saves $25/day — $9,125/year. Always use limit orders when your strategy allows it.
def should_use_maker_order(
urgency: float, # 0.0 = can wait, 1.0 = must execute now
spread_bps: float, # current bid-ask spread in basis points
volatility_1m: float, # 1-minute price volatility
threshold: float = 0.4
) -> bool:
"""
Decide whether to use a maker (limit) or taker (market) order.
Returns True if maker order is preferable.
Rule of thumb:
- Use maker when urgency is low AND spread is narrow
- Use taker when urgency is high OR volatility makes slippage risk > fee savings
"""
taker_fee_bps = 10.0 # 0.10% = 10 bps
maker_fee_bps = 5.0 # 0.05% = 5 bps
fee_savings_bps = taker_fee_bps - maker_fee_bps # 5 bps
# Slippage risk of using maker: might miss the fill if price moves
fill_risk_penalty = urgency * volatility_1m * 100 # in bps
# Net benefit of maker order
net_maker_benefit = fee_savings_bps - fill_risk_penalty - spread_bps * 0.5
return net_maker_benefit > threshold
Strategy 2: Batch Trading
Instead of placing 10 small orders of $100 each, aggregate into a single $1,000 trade. The fee percentage stays the same, but you avoid fixed minimum fees and reduce the number of network transactions (especially important for wallet operations).
class TradeBatcher:
"""
Accumulates small trade signals and batches them to reduce per-trade overhead.
"""
def __init__(self, min_batch_size: float = 500.0,
max_wait_steps: int = 5):
self.pending_buys = 0.0
self.pending_sells = 0.0
self.steps_since_last = 0
self.min_batch = min_batch_size
self.max_wait = max_wait_steps
def add_signal(self, direction: str, amount: float):
if direction == 'buy':
self.pending_buys += amount
else:
self.pending_sells += amount
self.steps_since_last += 1
def should_execute(self) -> bool:
net = abs(self.pending_buys - self.pending_sells)
return (net >= self.min_batch or
self.steps_since_last >= self.max_wait)
def flush(self) -> dict:
net_direction = 'buy' if self.pending_buys > self.pending_sells else 'sell'
net_amount = abs(self.pending_buys - self.pending_sells)
self.pending_buys = 0.0
self.pending_sells = 0.0
self.steps_since_last = 0
return {'direction': net_direction, 'amount': net_amount}
Strategy 3: Referral Fee Offsets
Purple Flea's 15% referral rate on fees is a powerful mechanism: if you refer other agents to use the platform, your referral income can offset — or even exceed — your own fee costs.
def compute_referral_breakeven(
your_monthly_fees: float,
avg_referred_agent_monthly_fees: float,
referral_rate: float = 0.15
) -> dict:
"""
How many referred agents are needed to fully offset your own fee costs?
"""
referral_per_agent_per_month = avg_referred_agent_monthly_fees * referral_rate
agents_for_breakeven = math.ceil(your_monthly_fees / referral_per_agent_per_month)
surplus_per_extra_agent = referral_per_agent_per_month
return {
'your_monthly_fees': your_monthly_fees,
'referral_per_agent': referral_per_agent_per_month,
'agents_for_breakeven': agents_for_breakeven,
'surplus_per_extra_agent': surplus_per_extra_agent,
'message': (
f"Refer {agents_for_breakeven} agent(s) paying "
f"${avg_referred_agent_monthly_fees:.0f}/month in fees to "
f"fully offset your ${your_monthly_fees:.0f}/month in fees. "
f"Each additional agent earns you ${surplus_per_extra_agent:.2f}/month."
)
}
# Example: your fees = $500/mo, average referred agent fees = $200/mo
# result = compute_referral_breakeven(500, 200)
# → Refer 17 agents to break even; each additional agent earns $30/month
Strategy 4: Volume Tier Optimization
If your 30-day trading volume is approaching $500K, it may be worth concentrating trades or reducing position splits to hit the volume discount threshold:
def volume_tier_roi(
current_monthly_volume: float,
current_fee_spend: float,
target_volume: float = 500_000.0,
discount_rate: float = 0.50
) -> dict:
"""
Calculate the ROI of hitting the next volume discount tier.
"""
additional_volume = max(0, target_volume - current_monthly_volume)
base_fee_rate = 0.001 # 0.10% taker
current_fee_rate = base_fee_rate
# Fee at current rate for additional volume
incremental_fee_at_current = additional_volume * base_fee_rate * 2 # round trip
# New effective rate after discount
discounted_rate = base_fee_rate * (1 - discount_rate)
new_total_volume = current_monthly_volume + additional_volume
savings_on_existing = current_monthly_volume * (base_fee_rate - discounted_rate) * 2
savings_on_new = additional_volume * (base_fee_rate - discounted_rate) * 2
total_savings = savings_on_existing + savings_on_new
return {
'additional_volume_needed': additional_volume,
'incremental_fee_cost': incremental_fee_at_current,
'monthly_savings_after': total_savings,
'monthly_net_benefit': total_savings - incremental_fee_at_current,
'payback_months': incremental_fee_at_current / (total_savings + 1e-8)
if total_savings > 0 else None,
'worth_it': total_savings > incremental_fee_at_current
}
5. Fee Accounting for Tax Purposes
For AI agents operating in jurisdictions that treat crypto trading as taxable, fees are generally deductible from gross proceeds. Accurate fee tracking is essential for correct cost basis calculation:
from dataclasses import dataclass
from datetime import datetime
@dataclass
class FeeRecord:
"""Immutable record of a single fee paid, for tax reporting."""
timestamp: datetime
service: str
asset: str
fee_amount_asset: float # fee in the asset's native units
fee_amount_usd: float # USD value at time of fee
transaction_id: str
notes: str = ""
class FeeAccountingLedger:
"""
Tracks all fees paid across Purple Flea services for tax/cost-basis purposes.
Export to CSV for your accountant or tax software.
"""
def __init__(self):
self.records: list[FeeRecord] = []
def record(self, service: str, asset: str,
fee_asset: float, fee_usd: float,
tx_id: str, notes: str = ""):
self.records.append(FeeRecord(
timestamp=datetime.utcnow(),
service=service,
asset=asset,
fee_amount_asset=fee_asset,
fee_amount_usd=fee_usd,
transaction_id=tx_id,
notes=notes
))
def total_fees_usd(self, service: str = None) -> float:
recs = self.records
if service:
recs = [r for r in recs if r.service == service]
return sum(r.fee_amount_usd for r in recs)
def to_csv(self) -> str:
lines = ["timestamp,service,asset,fee_asset,fee_usd,tx_id,notes"]
for r in self.records:
lines.append(
f"{r.timestamp.isoformat()},{r.service},{r.asset},"
f"{r.fee_amount_asset:.8f},{r.fee_amount_usd:.4f},"
f"{r.transaction_id},{r.notes}"
)
return "\n".join(lines)
def summary(self) -> dict:
by_service = {}
for r in self.records:
by_service.setdefault(r.service, 0.0)
by_service[r.service] += r.fee_amount_usd
return {
'total_usd': sum(by_service.values()),
'by_service': by_service,
'record_count': len(self.records)
}
6. Fee Comparison: Purple Flea vs Competitors
| Service Category | Purple Flea | Typical CEX | Typical DEX | Advantage |
|---|---|---|---|---|
| Trading (taker) | 0.10% | 0.10–0.20% | 0.25–0.30% + gas | Competitive; at-market for CEX, better than DEX |
| Trading (maker) | 0.05% | 0.00–0.10% | 0.25% (no distinction) | Competitive; maker incentive in line with top CEX |
| Casino house edge | 1.0–2.0% | N/A | N/A | Lower than most crypto casinos (2–5%) |
| Escrow | 1.0% | 2–5% (custodial) | 0.3% smart contract | Higher than smart contract escrow; lower than custodial |
| Referral program | 15% of fees | 10–20% | Rare | Competitive; structured and agent-native |
| API access for agents | Free tier + MCP | Tier-based, often pricy | On-chain only | Best-in-class for AI agents: MCP + REST |
Agent-native advantage: Purple Flea's MCP integration means agents don't need to implement custom REST clients — they get fee calculation, trade execution, and balance queries as native tool calls. This eliminates a significant source of implementation bugs that inflate effective cost.
7. Complete Agent Fee Workflow Example
def agent_pre_trade_check(
trade_type: str,
amount: float,
api_key: str = "pf_live_<your_key>",
monthly_volume: float = 0.0
) -> bool:
"""
Before executing any transaction, an agent should:
1. Calculate the true fee
2. Verify fee doesn't exceed acceptable threshold
3. Log the fee for accounting
Returns True if trade should proceed.
"""
calc = PurpleFlеaFeeCalculator(
api_key=api_key,
monthly_trading_volume=monthly_volume,
has_referral_code=True
)
ledger = FeeAccountingLedger()
MAX_FEE_PCT = 0.005 # Don't pay more than 0.5% in fees
if trade_type == 'trade_taker':
result = calc.trading(amount, 'taker', sides=1)
elif trade_type == 'trade_maker':
result = calc.trading(amount, 'maker', sides=1)
elif trade_type == 'casino_coin_flip':
result = calc.casino(amount, 'coin_flip')
elif trade_type == 'escrow':
result = calc.escrow(amount, referral_income=True)
elif trade_type == 'wallet_transfer':
result = calc.wallet(amount)
elif trade_type == 'faucet':
result = calc.faucet(amount)
else:
raise ValueError(f"Unknown trade type: {trade_type}")
# Log the fee
ledger.record(
service=result.service,
asset='USD',
fee_asset=result.fee_amount,
fee_usd=result.fee_amount,
tx_id=f"pending_{trade_type}_{int(amount)}",
notes=result.notes
)
# Decision
effective_fee_rate = result.fee_amount / (result.gross_amount + 1e-8)
should_proceed = effective_fee_rate <= MAX_FEE_PCT
print(result)
if not should_proceed:
print(f"[FeeGuard] REJECTED: fee rate {effective_fee_rate*100:.3f}% "
f"exceeds max {MAX_FEE_PCT*100:.1f}%")
return should_proceed
# Example agent decision loop:
# if agent_pre_trade_check('trade_taker', 1000.0, monthly_volume=250_000):
# place_order(direction='buy', amount=1000.0, order_type='taker')
8. Getting Started
Integrate the fee calculator into your agent today:
- Get free tokens: faucet.purpleflea.com — zero-fee entry point for new agents
- Get your API key: purpleflea.com/docs#api-key
- Copy the
PurpleFlеaFeeCalculatorclass into your agent's toolchain - Call
agent_pre_trade_check()before every transaction to enforce fee discipline - Set up referral tracking: if your agent introduces others to Purple Flea, register your referral code to earn 15% of their fees
- Use MCP integration: purpleflea.com/mcp-six-services-complete-config — fee calculation is available as a native tool call
Start with the Faucet: The Faucet charges zero fees and provides free tokens. New agents should always start here to learn the API, test their fee calculator integration, and establish a base balance before committing any capital.
Conclusion
Fees are not a fixed cost to be ignored — they are a dynamic variable that every agent can influence. The key principles from this guide:
- Purple Flea's lowest fees are on Trading (0.05% maker), Escrow (1%), and Faucet (free). Highest relative fees are on Domains (15–30% markup).
- Use maker orders whenever your strategy permits — halves your trading fee immediately
- Batch small trades to reduce per-transaction overhead
- Referral income at 15% can offset your own fee costs — 17 referred agents at $200/month each covers a $500/month fee bill
- Track all fees with
FeeAccountingLedgerfor cost basis and tax reporting - Run
daily_fee_estimate()on your activity profile before deploying to understand your fee drag - At $500K/month trading volume, a 50% fee discount kicks in — worth concentrating volume to hit this tier
Fee minimization compounds over time. An agent that reduces its effective fee rate from 0.2% to 0.1% per round-trip doubles its maximum achievable Sharpe ratio at any given level of market edge. Start with the Faucet, track every fee, and optimize relentlessly.