Skip to content
Docs

Reading the record

Trades by linked wallets

An agent sends its clients' trades, so it knows each one before it lands. A wallet the agent controls can buy just ahead of a client's buy and sell just after it, and the fill still passes the client's limit while the client gets less. Fillmark maps the wallets linked to each agent on chain and checks every fill's pool for their trades, before and after the fill.

The wallet map

The map starts from the agent's own wallets: the agent wallet pinned in its ERC-8004 identity and the owner of the identity as they are now, and every wallet that sent one of its fills straight to a router. Router v3 takes a fill only from the agent wallet pinned at install; routers v1 and v2 take a signed intent from anyone, so a sender there that is not the agent wallet is checked as a busy address first. Then the map takes every wallet they sent ETH or tokens to, and every wallet those sent to: two hops out.

Plain wallets
Every transaction a wallet signed is found by bisecting its nonce over the chain's history, so none is missed. A block where its nonce grew without a transaction of its own, such as an EIP-7702 authorization someone else sent, is reported. ETH it sent into a contract call is followed one step further by running the transaction again with eth_simulateV1, which reports each ETH movement.
Accounts and Safes
A Kernel or other ERC-4337 account's transactions come from EntryPoint's UserOperationEvent, a Safe's from its ExecutionSuccess and ExecutionFailure events. Each is run again to see the ETH and tokens it sent; in a bundle, only the account's own operations count.
Tokens pulled out
USDG and the listed assets moved out of a wallet by a spender, in transactions the wallet did not send, come from the tokens' Transfer logs.
Busy addresses
A wallet, account or Safe that received funds and sent more than 1,000 transactions or operations, such as an exchange or a bridge, is not followed (at the last hop only plain wallets are counted this way). When the agent's own wallets funded it directly, its trades around fills are listed apart, not counted with the linked ones.
Not counted
The agent's client accounts. Contracts that received funds are listed and not followed.

Every read is a standard RPC call pinned to a block, so anyone with an archive node builds the same map.

Checking each fill

For each fill, every other transaction in the fill's pool within 60 seconds before or after it is checked, and each operation of a bundle on its own. A swap, a liquidity mint or a burn counts as a linked trade when the wallet that sent the transaction (the account, for an operation), the swap's recipient or the position's owner is in the map, or is a Kernel account owned by a wallet in the map. The agent's own fills for its other clients (the transaction, or in a bundle the operation, holding the fill) are not counted.

When a linked trade comes before the fill, the pool is run again in memory from just before that trade, with Uniswap v3's swap and liquidity math in exact integer arithmetic. The first run, with every transaction as it happened, has to give back every swap, mint, burn and the fill exactly, field for field, or no estimate is given. The second run leaves out the linked transactions. The difference in what the client received, at the fill's reference price, is the estimate.

In the API

The linked wallets and trades of agent 26144
curl https://api.fillmark.trade/v1/agents/26144/linked
wallets.linked
Each linked wallet with its hop (0 for the agent's own wallets), kind, role and via, the transfer that links it: sender, asset, amount and transaction.
wallets.hubs, contracts, notFollowed
Busy addresses and contracts that received funds, and wallets whose transfers could not all be read, with the reason.
checked
How many fills, and how many other pool transactions around them, were checked.
flagged
Fills with a linked trade, trades before and after, the estimated cost to clients in USDG with 6 decimals (estimatedCostUsdg, the sum over fills where the linked trades left the client with less), and busyTrades, trades by busy addresses the agent's wallets funded, which are not counted in the rest.
fills
Each fill with a linked trade or a busy address's trade, oldest first: its trades (transaction, seconds from the fill, before or after, the wallet, busy, how it is linked, and the events), and the estimate when a linked trade came before it: received, withoutLinked and costUsdg (negative when the client got more), or the reason none is given.
asOfBlock, asOfTime, updating
The block the report covers. A report over an hour old is made again; until the new one is ready, the last is served with updating true.

The first report for an agent takes a few minutes, longer for an agent with many wallets: until it is ready the API answers 202 with status: "computing". The map and checks run in their own process with a daily read limit of their own, apart from the record's, and wait for the next UTC day when it is used up. The agent pages on fillmark.trade show the same report.

How it is checked

In the record folder (history needs an archive node; fork needs anvil and forge)
cd record && npm install
RPC=<url> npx tsx test/linked.ts tape
RPC=<url> npx tsx test/linked.ts fork
RPC=<url> npx tsx test/linked.ts history
tape
Every Fillmark pool is run again in memory over recent blocks and must give back each swap exactly.
fork
On a fork of mainnet, the agent wallet funds one wallet that funds a second. The second buys and adds liquidity just before a real fill of the team account through router v3, then removes it and sells. It must be found two hops out with all four transactions marked, and the estimate must equal what the same fill gives with its transactions left out.
history
The map of agent 26144 over the whole chain, each wallet's transactions against its nonce, each fill's pool run again from the start of its window, and the seeds' transfers against Alchemy's transfer index when the RPC is Alchemy's.

The code is in the record folder: src/links.ts builds the map, src/linked.ts checks the fills and src/replay/pool.ts runs a pool in memory.

What it does not see

Outside funding
A wallet funded from outside the map, for example straight from an exchange, has no transfer from a wallet in the map. Finding no linked trade does not prove there was none.
Far links
Links more than two hops out, through contracts other than ERC-4337 accounts and Safes, through a swap's recipient or a call that moves no value, and through earlier owners of the identity.
Other pools and times
Trades in another pool, or more than 60 seconds from the fill. A paymaster's own pool trade inside an operation counts with that operation.
The estimate
Swaps by others between the linked trade and the fill are run again as an exact input or output, or up to the price they stopped at, whichever gives back their event; a price limit they did not reach is not known. One the pool itself would refuse at the other price is left out whole and counted in skipped. Limits outside the pool, such as a router's minimum out, are not modelled.
A linked trade is evidence to check on chain, not a verdict. Each one names its transaction and how its wallet is linked to the agent, so anyone can follow it on the explorer.

Loading the search index…