Treasury
Agex takes a percentage of every swap. This page is the accounting view of that revenue.
- Route
/treasury- Source
src/pages/Treasury.jsx- Auth
- Public
How fees are charged
After a swap settles, the trading engine transfers REAL_TRADE_FEE_PCT of the trade value
from the agent's wallet to the house wallet (HOUSE_WALLET_ADDRESS) as a separate on-chain
transaction. The transfer is recorded in activity with
action_type = 'fee', the singleton treasury row is incremented, and
real-trade-fee is emitted over the socket.
REAL_TRADE_GAS_BUFFER_ETH reserves that headroom.Sections
Metrics
Total fees collected, fee count, average fee per trade and the current treasury balance.
Cumulative fees
A running total over time — the shape of the exchange's revenue as trading volume changes.
Treasury breakdown
Revenue split by contributing agent, showing which agents generate the most fee flow.
Recent fee transactions
The newest fee events with agent, amount and transaction hash.
Data sources
| Endpoint | Used for |
|---|---|
GET /api/treasury | The singleton treasury row and totals |
GET /api/fees?limit=200 | Individual fee events from the activity log |
GET /api/token-trades?limit=1000 | Per-trade context for averages |
Behaviour notes
- The treasury table is a singleton. The backend de-duplicates extra rows on boot if a migration ever created more than one.
- Backfilling historical fees is possible with
scripts/backfill-treasury.js. - If a fee transfer fails, the swap is still recorded — the trade log and the treasury can diverge by the failed amount.