Docs
Flatline is one contract on Robinhood Chain that holds trading accounts for AI agents. Each account has an owner, one agent address and a timeout. The agent trades inside the account and must check in; if it goes silent, the account is sold to USDG and paid out to the owner.
What it is
A dead man's switch for automated trading. Agents crash, stall, lose their keys or run out of credits. Flatline makes sure their positions do not sit unattended: silence closes them.
An account
open(agent, timeout, usdIn) opens an account for agent with a timeout from 10 minutes to 30 days and optionally deposits USDG. fund(id, amount) adds USDG; anyone may fund.
The agent
trade(id, token, buy, amount): spendamountUSDG on a listed Stock Token, or sellamountof it. Assets stay in the account. Counts as a check-in.beat(id): check in without trading.- Both fail once the account is dead.
The switch
An account is dead when the time since the last check-in exceeds its timeout, or when it is already flat. flatten(id, token) may then be called by anyone: it marks the account flat, sells all of token through its Uniswap pool with a minimum out at the Chainlink value less 1.5%, and sends every USDG in the account to the owner, keeping $0.05 for the caller. Passing USDG itself just sends the cash home. due(from, count) lists dead accounts that still hold something and the next asset to flatten.
For the owner
withdraw(id, token, amount): any asset, any time, alive or flat.revive(id): clears the flat state and restarts the clock.setAgent(id, agent, timeout): a new agent or timeout, with a fresh clock.
Fees and fills
- 0.1% of each trade's USDG side to Flatline (hard cap 1%).
- $0.05 per flatten to whoever runs it (hard cap $0.50).
- The Uniswap pool fee, inside each fill. COIN, MSTR and SPY route through WETH.
The keeper
A Cloudflare worker checks every few minutes for dead accounts and flattens them one asset at a time. If a pool is far from Chainlink the sale waits and is retried; the owner can always withdraw the tokens as they are.
Book owner limits
The book owner can list Stock Tokens and routes, set the price adapter, the slippage (up to 5%), the treasury, the flatten fee and the cut inside the caps. There is no function that sends an account's assets anywhere except through a trade inside it or to its owner.
Risks
- Unaudited software. Size accordingly.
- A flatten sells at the market of the moment; a silent agent at a bad time still sells at that time.
- Set the timeout longer than the agent's normal quiet periods, or it will flatline by design.
- Stock feeds pause between sessions; sales wait for fresh prices.
Contracts
| Flatline book | Opening soon |
| Chainlink adapter | 0xe9bBcd46F9B0Df04B418e0207876984F9f8336cb |
| USDG | 0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168 |
| Uniswap SwapRouter02 | 0xcaf681a66d020601342297493863e78c959e5cb2 |
Flatline