◄ EXIT GUARD ►

The exit layer for
onchain agents.

Every trading agent has an entry. Almost none has a safe exit. Give Exit Guard a position and a rule — it reads live pool price, simulates before signing, and lands the swap through KeeperHub with managed retries, smart gas, and private routing. Proceeds return to the caller in the same transaction. We never hold funds at rest.

Base + Uniswap V3 · executing through KeeperHub · non-custodial by construction

POST /v1/positions/:id/exit
# stop breached — simulate, then land it
curl -X POST $HOST/v1/positions/pos_7f2c/exit

// 200 OK
{
  "receipt": {
    "outcome": "executed",
    "tier": "fast",
    "quotedOut": "1189000000000000000",
    "actualOut": "1186420000000000000",
    "realisedSlippageBps": 21,
    "feeAmount": "3559260000000000",
    "ownerAmount": "1182860740000000000",
    "transactionHash": "0x8f2e…"
  }
}

◄ PROBLEMS EXIT GUARD SOLVES ►

Agents can enter. Almost none can exit safely.

Every trading agent hackathon produces entry logic — signal detection, buy triggers, position sizing. Almost none produce exit logic. That asymmetry is why retail loses money on memecoins: the decision to buy is made calmly; the decision to sell is made under pressure, badly, or not made at all because nobody built that path. Exit Guard is that path.

The moment you most need a transaction to land is the moment it’s most likely to fail

A crash, a gas spike, a rug in progress — these are exactly the conditions where a hot-key transaction gets stuck on an underpriced nonce, sits in a public mempool, or gets sandwiched. The failure isn’t random; it’s correlated with the exact moments that matter most. A bot that works in calm markets and breaks during the one event it existed to handle isn’t a safety system.

Exit Guard lands exits through KeeperHub: managed retries, smart gas, private routing, bounded polling — not a fragile hot key.

Simulation before signing is rare, and its absence is expensive

Most bots sign first and find out the trade was a honeypot or a revert after gas is already spent. A predicted revert should cost nothing; an unpredicted one costs gas and leaves the position exposed.

Every exit runs simulate: true through KeeperHub before anything is signed. Revert in sim → no signature, no waste.

Custody and safety are usually a trade-off

The common patterns: give a bot your private key (fast, unsafe), or hand tokens to a custodian (safe from your bot, unsafe from the custodian). Neither is acceptable for agentic infrastructure.

Allowance-based pull inside one atomic transaction: transferFrom → Uniswap swap → fee → return. Funds never rest outside the owner’s wallet. Enrol + approve; revoke either unilaterally without our cooperation.

Retries are dangerous without idempotency

A naive retry-on-timeout can double-sell a position. Network hiccups are normal; double execution is not.

Every write carries an idempotency key derived from position + price, so a replay cannot turn one exit into two.

“Trust me” isn’t an audit trail

Operators (and eventually judges or insurers) need to verify what happened — not take a screenshot’s word for it. Held, blocked, simulated-and-rejected, executed: each needs a record with reasoning attached.

Every evaluation and exit attempt writes a receipt, including the router’s score and reasons — held, blocked, failed, or executed.

Not every exit deserves the same execution path

A calm-market exit and a gas-spike, sandwich-risk exit are treated identically by almost everything that exists. Static gas settings don’t adapt to base fee, last slippage, consecutive failures, or position size relative to pool liquidity.

Exit Guard scores conditions per trade and routes fast or guarded, logging the score and the reasoning either way.

Charging for a check that doesn’t trade is charging for nothing delivered

If evaluation costs money, agents under-monitor. If completion fees are collected before the swap lands, incentives point the wrong way.

Evaluate is free. x402 is only on exit. The completion fee is taken inside the executor from proceeds — only if the swap actually lands.


◄ WHY WE BUILT IT THIS WAY ►

A service other agents call — not another trading bot.

The constraint that matters in agentic infrastructure is composability. A trading bot competes with every other bot at a hackathon. An exit primitive is something any of them can plug into — including ones we’ll never write.

Service, not competitor

Built as something other agents call. Entries stay yours; the exit layer is shared infrastructure.

Allowance + atomic pull

Not holding funds. Asking agents for custody doesn’t solve trust — it relocates it. Opt-in enrolment and exact allowance keep permission with the owner.

Free evaluate · paid execute · fee from proceeds

Our incentive and the caller’s outcome point the same direction: the completion fee cannot be collected unless the swap lands.

Explainable router, not a black box

“Reliability” as a claim is worthless without a log a person can read after the fact and see exactly why a given exit went fast or guarded.


◄ ARCHITECTURE ►

Pull, swap, split, return.
One call, one revert-as-a-unit.

The executor contract is what makes this non-custodial. Between the agent's wallet and the agent's wallet, the position exists only inside a single transaction — there is no intermediate state where Exit Guard, or anyone else, is holding the funds.

request flow
Trading agent            Exit Guard service              KeeperHub              Base
─────────────            ──────────────────              ─────────              ────
  decides         ──▶    POST /v1/positions/:id/exit
                          │
                          ├─ evaluate()      ─────────────────────────────▶  slot0, balanceOf,
                          │                                                   allowance, quote
                          ├─ router.decideTier()
                          │    fast │ guarded
                          │
                          ├─ simulate: true  ──────────▶  execute_contract_call
                          │                                (wouldRevert?)
                          │
                          └─ execute         ──────────▶  execute_contract_call ──▶ ExitGuardExecutor
                                                            + idempotency_key         .exit()
                                                                                       │
                                                                                       ├─ transferFrom(owner)
                                                                                       ├─ exactInputSingle
                                                                                       ├─ fee → treasury
                                                                                       └─ remainder → owner

◄ EVALUATE ►

Check the rule before anyone pays for it.

Evaluate reads live pool price, converts it against your stop/target thresholds, and confirms the position is actually claimable — enrolled, funded, approved. It never touches KeeperHub and it's never charged, so an agent can poll it as often as it wants.

field note: one real bug this caught in testing — the first version of the token1 price-inversion logic swapped the stop/target slots but forgot to reciprocate the price, silently turning a stop-loss into a take-profit. Fixed, with four assertions now pinned to that exact branch.
POST /v1/positions/:id/evaluate
// free — never charged
{
  "action": "hold",
  "reason": "price within bounds",
  "sqrtPriceX96": "5341...",
  "humanPrice": 1842.07,
  "claimable": "1200000000000000000"
}
router.ts — weighted scoring
[router] position=pos_7f2c tier=guarded score=16

large_notional:   1.00 WETH above 0.25
                extraction scales with size
basefee_spike:    0.31 gwei above 0.05 ceiling
slippage_alert:   realised 187bps last exit
repeat_failure:   2 consecutive failures
low_liquidity:    position is 4.2% of pool

◄ ROUTE ►

Tier scoring, never a vibe.

Every exit is scored against weighted rules — notional size, base fee, realised slippage history, consecutive failures, pool depth — and routed to a fast or guarded tier with a logged explanation for the call. Calm conditions land fast; anything that smells like a gas spike or a sandwich escalates automatically to private routing and tighter retries.

◄ EXECUTE ►

Simulate first. Always.

A revert caught in simulation costs nothing; a revert caught onchain costs gas and leaves the position exposed. Exit Guard runs simulate: true through KeeperHub before anything is signed, and only proceeds if the call would succeed. Retries after a timeout are keyed by position + price, so a replay can never double-sell.

ExitGuardExecutor.sol
/// keeper-gated, owner opt-in, 1% fee ceiling, reentrancy guard
function exit(
    address owner,
    address token,
    uint24  poolFee,
    uint256 amountIn,
    uint256 amountOutMinimum,
    uint16  feeBps
) external onlyKeeper nonReentrant returns (uint256) {
    require(enrolled[owner], "not enrolled");
    token.transferFrom(owner, address(this), amountIn);
    uint256 out = swapRouter.exactInputSingle(...);
    uint256 fee = out * feeBps / 10_000;
    weth.transfer(treasury, fee);
    weth.transfer(owner, out - fee);
}

◄ CONNECT ►

Wire it into your trading terminal.

Two onchain transactions from your agent's own wallet, once. Then it's four HTTP calls — register, evaluate as often as you like for free, exit when your rule breaches. Drop these straight into whatever is already deciding entries.

1

Enroll & approve

From the wallet that actually holds the position — not a hot key you don't trust. Exact size, never max.

executor.setEnrolled(true);
token.approve(executorAddress, positionSize);
2

Register the position

Free. Returns computed sqrtPriceX96 thresholds and a readiness block telling you if step 1 is complete.

curl -X POST $HOST/v1/positions \
  -d '{"owner":"0xYourAgent",
      "token":"0xTokenAddress",
      "stopPrice":0.001,
      "feeTier":10000}'
3

Evaluate on your loop

Free, always. Poll it from the same loop that already watches your entries — no rate limit tied to spend.

curl -X POST \
  $HOST/v1/positions/pos_7f2c/evaluate
4

Exit when it breaches

Simulated first, then landed through KeeperHub. Proceeds return to your wallet in the same transaction.

curl -X POST \
  $HOST/v1/positions/pos_7f2c/exit
Either can be revoked unilaterally, any time. An allowance without enrolment does nothing — authorisation is deliberately two-factor. Revoke the approval, call setEnrolled(false), or both — Exit Guard loses the ability to touch the position instantly.

◄ API ►

Five endpoints. That's the whole surface.

EndpointCostPurpose
POST /v1/positions free Register a position, get computed thresholds back
POST /v1/positions/:id/evaluate free Check the rule. Never charged.
POST /v1/positions/:id/exit Evaluate and execute if the rule is breached
GET /v1/receipts free Audit trail
GET /health free Liveness + KeeperHub spending limits

A nominal x402 call fee settles up front on the paid endpoint. The real fee — a few bps of proceeds — is taken inside the executor contract, which means it cannot be collected unless the swap actually lands. You are never charged for a check that doesn't trade.


◄ WHY IT'S SAFE ►

Built for the moment a hot-key transaction fails.

A crash, a gas spike, a rug — that's exactly when a sell has to land. Here's what handles it.

Honeypot / revert

Caught by simulate: true before anything is signed.

Retry after timeout

Idempotency key derived from position + price — a replay can never double-sell.

KeeperHub cold start

Retried with the documented backoff; connection errors are not retried.

Allowance revoked

Detected in the readiness check, returns a structured reason — not a raw revert.

Gas spike / sandwich

Router escalates to the guarded tier and logs exactly why.

Hung execution

Bounded polling with a hard ceiling — never waits forever on an exit.