affaan-m/ECC · error · SpendLimitError

Daily limit: + >

Error message

Daily limit: ${daily} + ${usd_amount} > ${MAX_DAILY_SPEND_USD}

What it means

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.

Solutions

  1. Halt new trades for the rest of the window when the daily cap trips
  2. Persist spend records durably so restarts cannot reset the budget
  3. Alert on-call when the daily limit is approached
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at skills/llm-trading-agent-security/SKILL.md:67 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of affaan-m/ECC@d8409a4b08 (2026-08-26). Data as JSON: /api/errors/481692e9d8d1277a. Report an issue: GitHub.

Appendix: source

Thrown at skills/llm-trading-agent-security/SKILL.md:67

### Hard spend limits

```python
from decimal import Decimal

MAX_SINGLE_TX_USD = Decimal("500")
MAX_DAILY_SPEND_USD = Decimal("2000")

class SpendLimitError(Exception):
    pass

class SpendLimitGuard:
    def check_and_record(self, usd_amount: Decimal) -> None:
        if usd_amount > MAX_SINGLE_TX_USD:
            raise SpendLimitError(f"Single tx ${usd_amount} exceeds max ${MAX_SINGLE_TX_USD}")

        daily = self._get_24h_spend()
        if daily + usd_amount > MAX_DAILY_SPEND_USD:
            raise SpendLimitError(f"Daily limit: ${daily} + ${usd_amount} > ${MAX_DAILY_SPEND_USD}")

        self._record_spend(usd_amount)
```

### Simulate before sending

```python
class SlippageError(Exception):
    pass

async def safe_execute(self, tx: dict, expected_min_out: int | None = None) -> str:
    sim_result = await self.w3.eth.call(tx)

    if expected_min_out is None:
        raise ValueError("min_amount_out is required before send")

    actual_out = decode_uint256(sim_result)
    if actual_out < expected_min_out:

View on GitHub (pinned to d8409a4b08)