feat(plugin-defi): add Bhairab pre-trade token risk scan - #584
Conversation
Adds a BHAIRAB_SCAN_TOKEN action — a pre-trade safety check that returns a proceed/caution/stop verdict for a Solana token from live market signals (liquidity, 24h move, volume, token age). Fills a gap: the kit can swap and trade tokens but has no way to vet a token's risk first, so agents can walk into illiquid, crashing, or scam tokens. This adds that guardrail as a composable action. Works with no API key (heuristic verdict). Setting BHAIRAB_API_KEY in the agent config unlocks an AI-reasoned verdict. - bhairab/tools/scan_token.ts — typed fetch wrapper - bhairab/actions/scanToken.ts — Action with zod schema, similes, examples - register in plugin-defi methods + actions - add optional BHAIRAB_API_KEY to core Config
|
Hey @thearyanag @michaelessiet,flagging this one in case it's useful. The kit can swap and trade tokens, but there's no built-in way for an agent to vet a token before buying it. So autonomous agents can walk into honeypots and rugs at machine speed. This adds a BHAIRAB_SCAN_TOKEN action that returns proceed / caution / stop from live market signals + on-chain authority checks (it catches freeze-authority honeypots, the "buy but can't sell" trap). Kept it deliberately low-footprint: +178 / −0, additive only, slots into plugin-defi like the other integrations (OKX, Drift, Lulo), no changes to existing behavior Happy to adapt it however fits your roadmap: move it to a standalone plugin, add docs/tests, or adjust the action shape. Just let me know what you'd prefer and I'll turn it around quickly. |
What
Adds a
BHAIRAB_SCAN_TOKENaction toplugin-defi: a pre-trade safety check that returns aproceed/caution/stopverdict for a Solana token, based on live market signals (liquidity, 24h price move, volume, token age, pair count).Why
The kit can already swap and trade tokens, but there's no built-in way for an agent to vet a token's risk before buying it. Autonomous agents trading trending tokens can walk straight into illiquid, crashing, or scam tokens. This adds that guardrail as a composable action an agent can call before executing a trade.
Usage
Because it's a registered action, the agent's model can also call it autonomously as a safety step before a swap.
BHAIRAB_API_KEYin the agent config unlocks an AI-reasoned verdict.Changes
plugin-defi/src/bhairab/tools/scan_token.ts— typed fetch wrapperplugin-defi/src/bhairab/actions/scanToken.ts—Actionwith zod schema, similes, examplesplugin-defimethods+actionsBHAIRAB_API_KEYto coreConfigTesting
pnpm buildpasses forcoreandplugin-defi(including DTS typecheck)biome checkclean on the new filesproceed, unknown mint →caution