New.space / artifacts /bounty-agent /execution_policy.py
Cryptostoner's picture
Deploy verified Autonomous Revenue Agent V2 Docker build
18535e8 verified
Raw History Blame Contribute Delete
3.55 kB
from typing import Any
from fastapi import FastAPI
BASE_GAS_POLICY = {
"network": "base-mainnet",
"chain_id": 8453,
"soft_planning_usd": 0.05,
"hard_ceiling_usd": 0.08,
"wallet_test_float_usd": 0.50,
"rule": "Cheaper confirmed gas is allowed. Unknown gas or gas above 0.08 USD does not execute.",
}
RECENT_BASE_SAMPLE = {
"sampled_at_context": "2026-07-06 EC2 live Base RPC sample",
"latest_block": 48295042,
"sampled_recent_receipts": 100,
"fee_history_blocks": 1024,
"eth_usd": 1806.37,
"receipt_effective_gwei_p50": 0.024,
"receipt_effective_gwei_p95": 0.643892412,
"receipt_effective_gwei_p99": 1.689792592,
"receipt_gas_used_p50": 38521,
"receipt_gas_used_p95": 185481,
"p95_cost_usd_by_gas_units": {
"21000": 0.024425,
"50000": 0.058155,
"100000": 0.116311,
"150000": 0.174466,
"250000": 0.290777,
},
"p95_gas_units_fit_under_0_08_usd": 68781,
}
TASK_CLASSES = {
"platform_verification": {
"examples": ["CoW order lookup", "CoW trade lookup", "bounty report status", "payment receipt check"],
"expected_spend_usd": 0.0,
"wallet_required": False,
"execution": "read_only_api_or_rpc",
"next_stage": "allowed when evidence status is verified",
},
"offchain_signature_or_intent": {
"examples": ["CoW signed intent", "x402 metadata", "platform API submission"],
"expected_gas_usd": 0.0,
"wallet_required": "only for signing when platform requires it",
"execution": "no onchain broadcast unless a later settlement transaction is explicitly estimated",
},
"base_micro_transaction": {
"examples": ["native transfer", "small approval", "simple contract call"],
"expected_gas_units": "21000-68000 under p95 sample for 0.08 USD ceiling",
"hard_ceiling_usd": 0.08,
"execution": "estimate first, execute only if gas is confirmed and <= hard ceiling",
},
"complex_contract_or_solver_settlement": {
"examples": ["CoW solver settlement", "multi-call hooks", "flash-loan settlement", "contract deployment"],
"expected_gas_units": ">=100000 common",
"sampled_p95_cost_usd": ">=0.116 for 100000 gas at sampled p95 effective gas",
"execution": "do not run from the 0.50 USD test wallet unless dry-run confirms gas <= 0.08 USD and platform authenticity is verified",
},
}
OFFICIAL_DOCS = {
"coinbase_authentication": "https://docs.cdp.coinbase.com/get-started/authentication/overview",
"coinbase_supported_networks": "https://docs.cdp.coinbase.com/get-started/supported-networks",
"cow_orderbook_api": "https://docs.cow.fi/cow-protocol/reference/apis/orderbook",
"cow_solvers": "https://docs.cow.fi/cow-protocol/concepts/introduction/solvers",
"cow_llms": "https://docs.cow.fi/llms.txt",
}
def execution_policy() -> dict[str, Any]:
return {
"base_gas_policy": BASE_GAS_POLICY,
"recent_base_sample": RECENT_BASE_SAMPLE,
"task_classes": TASK_CLASSES,
"official_docs": OFFICIAL_DOCS,
"agent_instruction": "For revenue tasks, prefer read-only verification and offchain platform actions. Any onchain broadcast must have confirmed platform authenticity, transaction details, and estimated Base gas <= 0.08 USD.",
}
def register_execution_policy_routes(app: FastAPI) -> None:
@app.get("/api/v2/execution-policy")
async def get_execution_policy() -> dict[str, Any]:
return execution_policy()