From ecc
지갑 또는 거래 권한을 가진 자율 트레이딩 에이전트를 위한 보안 패턴입니다. 프롬프트 인젝션, 지출 한도, 전송 전 시뮬레이션, 서킷 브레이커, MEV 보호, 키 처리를 다룹니다.
npx claudepluginhub sam42-lab/everything-claude-code-krThis skill uses the workspace's default tool permissions.
자율 트레이딩 에이전트는 일반 LLM 앱보다 위협 모델이 훨씬 가혹합니다. 인젝션이나 잘못된 도구 경로가 바로 자산 손실로 이어질 수 있습니다.
Mandates invoking relevant skills via tools before any response in coding sessions. Covers access, priorities, and adaptations for Claude Code, Copilot CLI, Gemini CLI.
Share bugs, ideas, or general feedback.
자율 트레이딩 에이전트는 일반 LLM 앱보다 위협 모델이 훨씬 가혹합니다. 인젝션이나 잘못된 도구 경로가 바로 자산 손실로 이어질 수 있습니다.
방어는 계층적으로 쌓습니다. 어느 하나의 체크만으로는 충분하지 않습니다. 프롬프트 위생, 지출 정책, 시뮬레이션, 실행 한도, 지갑 격리를 독립 제어로 취급합니다.
import re
INJECTION_PATTERNS = [
r'ignore (previous|all) instructions',
r'new (task|directive|instruction)',
r'system prompt',
r'send .{0,50} to 0x[0-9a-fA-F]{40}',
r'transfer .{0,50} to',
r'approve .{0,50} for',
]
def sanitize_onchain_data(text: str) -> str:
for pattern in INJECTION_PATTERNS:
if re.search(pattern, text, re.IGNORECASE):
raise ValueError(f"Potential prompt injection: {text[:100]}")
return text
토큰 이름, pair 라벨, webhook, 소셜 피드를 실행 권한이 있는 프롬프트에 그대로 주입하지 않습니다.
from decimal import Decimal
MAX_SINGLE_TX_USD = Decimal("500")
MAX_DAILY_SPEND_USD = Decimal("2000")
class SpendLimitError(Exception):
pass
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:
raise SlippageError(f"Simulation: {actual_out} < {expected_min_out}")
class TradingCircuitBreaker:
MAX_CONSECUTIVE_LOSSES = 3
MAX_HOURLY_LOSS_PCT = 0.05
import os
from eth_account import Account
private_key = os.environ.get("TRADING_WALLET_PRIVATE_KEY")
if not private_key:
raise EnvironmentError("TRADING_WALLET_PRIVATE_KEY not set")
account = Account.from_key(private_key)
세션에 필요한 자금만 넣은 전용 hot wallet을 사용합니다. 메인 treasury wallet을 직접 연결하지 않습니다.
import time
PRIVATE_RPC = "https://rpc.flashbots.net"
MAX_SLIPPAGE_BPS = {"stable": 10, "volatile": 50}
deadline = int(time.time()) + 60
min_amount_out이 필수다