jepeta.
Jepeta/Guides/Agent Api
Agent Api · Base / 8453

How do I add a pre-trade risk gate to a Base trading bot?

Design a safe deterministic gate before a Base swap

Direct answer

Put the risk gate before transaction construction or signing: resolve the exact Base token, call a deterministic risk API, validate the schema, and convert the result into explicit stop/review/continue rules. Do not let an LLM free-form its way around missing evidence.

Where the gate belongs

The gate should run after token identity is known but before funds are committed. That gives it the exact contract address while still allowing a hard stop with no trade side effect.

Keep the gate separate from alpha or price logic. Security screening answers whether execution should proceed under safety policy, not whether the trade is expected to be profitable.

Recommended control flow

Reject malformed addresses, wrong-chain assets, non-200 API responses, and invalid schemas. Stop on BLOCK. Send WARN to additional policy checks or human review. Let PASS continue only if slippage, position-size, price, and other trading rules also pass.

Cache cautiously. Token permissions and market conditions can change, so an old verdict should not be treated as durable authorization.

Auditability

Store the token address, decision, key evidence fields, source status, and observation time with the bot's decision log. If a permanent Jepeta evidence page exists, store its canonical URL as an external verification reference.

Do not copy paid-only evidence into public logs unless your own data policy explicitly allows it.

Practical checklist

  • Gate before signing
  • Exact contract only
  • Schema validation
  • Fail closed
  • Separate risk from alpha
  • Persist timestamped decision evidence

Limitations

This is educational risk-screening content, not investment advice. Token and market conditions can change after any snapshot. A PASS result or negative honeypot signal is not a safety guarantee.