{"record":{"id":"806f47205ef9899d","repo":"affaan-m/ECC","slug":"simulation-actual-out-expected-min-out","errorCode":null,"errorMessage":"Simulation: {actual_out} < {expected_min_out}","messagePattern":"Simulation: (.+?) < (.+?)","errorType":"exception","errorClass":"SlippageError","httpStatus":null,"severity":"error","filePath":"skills/llm-trading-agent-security/SKILL.md","lineNumber":86,"sourceCode":"\n        self._record_spend(usd_amount)\n```\n\n### Simulate before sending\n\n```python\nclass SlippageError(Exception):\n    pass\n\nasync def safe_execute(self, tx: dict, expected_min_out: int | None = None) -> str:\n    sim_result = await self.w3.eth.call(tx)\n\n    if expected_min_out is None:\n        raise ValueError(\"min_amount_out is required before send\")\n\n    actual_out = decode_uint256(sim_result)\n    if actual_out < expected_min_out:\n        raise SlippageError(f\"Simulation: {actual_out} < {expected_min_out}\")\n\n    signed = self.account.sign_transaction(tx)\n    return await self.w3.eth.send_raw_transaction(signed.raw_transaction)\n```\n\n### Circuit breaker\n\n```python\nclass TradingCircuitBreaker:\n    MAX_CONSECUTIVE_LOSSES = 3\n    MAX_HOURLY_LOSS_PCT = 0.05\n\n    def check(self, portfolio_value: float) -> None:\n        if self.consecutive_losses >= self.MAX_CONSECUTIVE_LOSSES:\n            self.halt(\"Too many consecutive losses\")\n\n        if self.hour_start_value <= 0:\n            self.halt(\"Invalid hour_start_value\")","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/affaan-m/ECC/blob/d8409a4b0813771235555e32e3d8046a73988bfa/skills/llm-trading-agent-security/SKILL.md#L68-L104","documentation":"Illustrative slippage guard from the llm-trading-agent-security skill: the eth.call simulation returned an output amount below expected_min_out, so the price moved beyond the accepted slippage and the transaction is not signed or sent.","triggerScenarios":"Thrown at skills/llm-trading-agent-security/SKILL.md:86 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-quote and rebuild the transaction with a fresh min_amount_out","Cap acceptable slippage per pair based on liquidity","Retry a bounded number of times before surfacing to the operator"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d8409a4b0813771235555e32e3d8046a73988bfa","analyzedAt":"2026-08-26T12:15:34.022Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}