{"record":{"id":"481692e9d8d1277a","repo":"affaan-m/ECC","slug":"daily-limit-daily-usd-amount-max-dail","errorCode":null,"errorMessage":"Daily limit: ${daily} + ${usd_amount} > ${MAX_DAILY_SPEND_USD}","messagePattern":"Daily limit: (.+?) \\+ (.+?) > (.+?)","errorType":"exception","errorClass":"SpendLimitError","httpStatus":null,"severity":"error","filePath":"skills/llm-trading-agent-security/SKILL.md","lineNumber":67,"sourceCode":"### Hard spend limits\n\n```python\nfrom decimal import Decimal\n\nMAX_SINGLE_TX_USD = Decimal(\"500\")\nMAX_DAILY_SPEND_USD = Decimal(\"2000\")\n\nclass SpendLimitError(Exception):\n    pass\n\nclass SpendLimitGuard:\n    def check_and_record(self, usd_amount: Decimal) -> None:\n        if usd_amount > MAX_SINGLE_TX_USD:\n            raise SpendLimitError(f\"Single tx ${usd_amount} exceeds max ${MAX_SINGLE_TX_USD}\")\n\n        daily = self._get_24h_spend()\n        if daily + usd_amount > MAX_DAILY_SPEND_USD:\n            raise SpendLimitError(f\"Daily limit: ${daily} + ${usd_amount} > ${MAX_DAILY_SPEND_USD}\")\n\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:","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/affaan-m/ECC/blob/d8409a4b0813771235555e32e3d8046a73988bfa/skills/llm-trading-agent-security/SKILL.md#L49-L85","documentation":"Illustrative daily-budget guard from the llm-trading-agent-security skill: the rolling 24h spend plus the proposed amount would exceed MAX_DAILY_SPEND_USD, so SpendLimitGuard raises before recording the spend. It fires only after the single-tx check passed.","triggerScenarios":"Thrown at skills/llm-trading-agent-security/SKILL.md:67 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Halt new trades for the rest of the window when the daily cap trips","Persist spend records durably so restarts cannot reset the budget","Alert on-call when the daily limit is approached"],"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"}