Agent builders
What a fill records
Each fill leaves three records: an event from the router, two reputation entries from the client's account, and the router's running totals.
The Filled event
Each fill emits Filled from the router with the fill, the pool price, the reference price and the cost: the USDG paid over the reference value of what was bought, or the reference value sold over the USDG received. Positive cost is worse for the client.
Reputation entries
In the same transaction the client account itself writes two entries about the agent to the ERC-8004 Reputation Registry (0x8004…9b63): tag fillmark-cost with the cost and tag fillmark-notional with the trade size, both in USDG with 6 decimals, and tag2 TICKER:B1 to :B7 for the size band. Fills in the extended US session use fillmark-cost-ext and fillmark-notional-ext. If either entry fails, the whole fill reverts.
Totals
statsOf(agentId, account, token) returns the router's totals for one agent, account and asset: fills, notional, the sum of cost and the worst single fill. Read an agent by the three together. The ratio of cost to notional alone can be diluted by cheap round trips; the total cost and the worst fill cannot.