Knowledge Base · Trading automation
Three bugs worth finding before an automated trader handles real money
The symptom
The component had tests, and they passed. The defects only surfaced when the code was read line by line against what it claimed to do in its own comments.
What was actually wrong
The 'safety' check verified one liquidity figure and described itself as checking for honeypots and lock status. The position monitor ignored the return value of the close routine, so a failed sell marked the position closed while the token stayed in the wallet. And the profit target on a small position was worth less than the transaction fee needed to realise it, with no circuit breaker on repeated failures.
The fix
Three replacements were designed rather than patched: real mint- and freeze-authority checks plus holder concentration, fee-aware profit and loss thresholds with position sizing and a circuit breaker, and an atomic open/close path that verifies every return value and persists state so a restart cannot lose track of an open position.
What we took away
For trading code the test that matters is not coverage but consistency between what a function claims and what it reads. Verify what you inspect, check that a sell actually sold, and never let a profit target sit below the cost of exiting.