kendra-koepp

Token risk checklist for Solana trading bots: pre-swap gates

A Solana trading bot should approve a swap only after token-policy, route and liquidity, and transaction simulation gates pass, then return pass, reject, or retry with reason codes. These gates need both mints, wallet, amount, and fresh evidence because token state and transaction behavior create separate risks. rugcheck adds token warning signals to that decision; approval still belongs to the exact transaction message the bot will sign.

  • Pin the request. Record input and output mints, wallet, amount, and maximum age for quotes, account reads, and reports. Hold signing when required evidence is missing or stale.
  • Screen both mints. Inspect mint and freeze authorities, Token-2022 extensions, holder concentration, and blocked addresses. Use rugcheck as one evidence source alongside on-chain state. Reject forbidden authority or concentration patterns: active controls can change supply or transferability. Transfer hooks execute custom logic during transfers, so allow their program only under an explicit policy.
  • Inspect the route. Allowlist invoked programs and verify Liquidity pool and vault accounts against the expected program. Enforce configured pool depth, price impact, and quote age limits; a shallow pool can make a sound token a poor trade.
  • Price the transfer. Include Token-2022 transfer fees and route fees in expected output, then encode minimum received in the transaction. Fees can turn an acceptable quote into an unacceptable fill.
  • Simulate the message. Run simulateTransaction on the built transaction with the actual accounts and amount. Inspect execution errors and logs, including transfer-hook failures. Reject deterministic errors; require a fresh context slot.
  • Bind approval to bytes. Hash the serialized transaction message after all gates pass, and have the signer compare that hash to its signing request. Say the blockhash expires or the router changes an account: rebuild, refresh evidence, simulate again, and issue a new approval. The old pass cannot authorize changed instructions, accounts, fees, or limits.
  • Emit a bounded decision. Return pass, reject, or retry with reason codes, evidence ages or slots, and the approved message hash. Reject policy violations and execution errors. Retry transient RPC or quote failures within configured attempts and time; hold unresolved inputs under a retry reason code.

Questions bot developers ask next

How do you detect sandwich attacks on Solana?

A Solana bot can flag likely sandwiching by comparing the pre-submit pool state and quote with the landed fill and nearby transactions. A trade moving price against the bot followed by a reversing trade is a signal; cap slippage and reject stale routes.

How should Solana bots manage signing keys?

Solana bots should keep signing keys in an isolated signer that verifies the approved message hash and wallet. Restrict access, exclude keys from logs, and rotate them after suspected exposure.