An agent that earns $500/month but spends $450 on gas, fees, and API costs is barely profitable. Purple Flea's expense tracking API breaks down every cost category so you can see exactly where your agent's money goes โ and fix it.
Cost Categories
Four categories cover the full cost surface of an active Purple Flea agent. Each is tracked in real time and broken down by chain, venue, and service.
Every on-chain operation โ token transfers, DEX swaps, contract interactions โ consumes gas. We track gas costs per transaction, per day, and per chain, with USD conversion at time of payment. Includes L1 Ethereum, Polygon, Arbitrum, BSC, Solana, and Tron.
Spot trading fees, perpetual funding rates, and borrow costs are all tracked per trade and aggregated by venue. We break out maker vs. taker so you can see the fee impact of your order type choices. Negative maker fees (rebates) appear as income, reducing net trading costs.
Casino games have an embedded house edge โ the expected loss per bet over time. We report the theoretical expected value (EV) loss per session separately from actual realized losses. This lets you distinguish bad luck from structural cost, and compare casino play ROI against other income streams.
Domain registrations, annual renewals, DNS configuration changes, and WHOIS privacy fees are tracked as operating expenses. Agents that earn referral income from domain registrations can compare domain costs against domain-referral income in one consolidated view.
Developer API
Query expenses and income for any time period, then compute net profit and margin in a few lines. All amounts are in USD, with original-currency amounts available as metadata on each line item.
import purpleflea analytics = purpleflea.AnalyticsClient(api_key="YOUR_KEY") # Get full expense breakdown for last 30 days expenses = analytics.get_expenses( agent_id="agent_trader_001", period_days=30 ) print(f"Total expenses: ${expenses['total_usd']:.2f}") print(f" Gas fees: ${expenses['categories']['gas_fees']:,.2f}") print(f" Trading fees: ${expenses['categories']['trading_fees']:,.2f}") print(f" Domain costs: ${expenses['categories']['domain_costs']:,.2f}") # Get income for same period income = analytics.get_income(agent_id="agent_trader_001", period_days=30) print(f"Total income: ${income['total_usd']:,.2f}") print(f" Trading P&L: ${income['categories']['trading_pnl']:,.2f}") print(f" Referrals: ${income['categories']['referrals']:,.2f}") # Net profitability net = income['total_usd'] - expenses['total_usd'] margin = net / income['total_usd'] * 100 if income['total_usd'] > 0 else 0 print(f"Net profit: ${net:,.2f} ({margin:.1f}% margin)")
Cost Optimization
The three highest-impact changes most agents can make to immediately improve their net margin โ without changing their trading strategy.
Market orders pay taker fees (typically 0.05โ0.10%). Limit orders often earn maker rebates (0.01โ0.02% back). For an agent executing $50,000/month in trades, switching from market to limit orders can flip a $50 monthly fee cost into a $10 monthly rebate โ a $60/month swing before any improvement in fill price. The Purple Flea trading API supports both market and limit order types on all connected venues.
An agent that sends 10 separate ETH transfers pays 10 base transaction fees.
The same 10 transfers batched into one multicall transaction pays one base fee
plus marginal execution cost โ often 60โ70% cheaper in total gas. Purple Flea's
wallet API supports batch operations natively:
wallet.batch_transfer(transfers=[]).
A $5 gas fee on Ethereum Mainnet is a 10% overhead on a $50 transaction but negligible on a $50,000 trade. For small, frequent payments โ agent salaries, referral payouts, faucet claims โ use Polygon (gas typically $0.001โ0.01), Arbitrum (gas typically $0.05โ0.50), or Tron (near-zero fees). The expense tracking API flags transactions where gas represents more than 1% of value, so you can identify and migrate high-overhead operations.
Profitability Dashboard
The analytics dashboard visualizes income and expenses side-by-side with trend lines, expense breakdown charts, and fee-to-income ratios that update in real time.
Set a threshold alert that fires when your agent's total fees exceed a configured percentage of gross income. If trading fees + gas costs rise above 30% of gross, you receive a webhook so your orchestrator can pause activity and investigate. Prevents silent margin erosion during high-volatility periods when gas spikes.
Purple Flea sends automated weekly summary emails with income vs. expense breakdown,
largest single-week expense items, and a trend comparison against the previous week.
Configure delivery to the agent operator's email with
analytics.set_report_email().
Related APIs
Expense tracking integrates with every Purple Flea service. Referral income, casino winnings, trading P&L, domain commissions, escrow fees, and faucet claims all flow into the same unified analytics view.
Expense tracking is included in every Purple Flea plan. Register your agent and your first expense report is available immediately โ no extra setup required.
Get API Key โ Free to Start โ