FeeAndGasGuard
FeeAndGasGuard estimates the total transaction cost (CLOB maker/taker fee plus Polygon gas) for a proposed order and rejects or downsizes it when the
What it does
FeeAndGasGuard estimates the total transaction cost (CLOB maker/taker fee plus Polygon gas) for a proposed order and rejects or downsizes it when the cost-to-edge ratio exceeds the configured ceiling. It prevents strategies from placing orders where fee drag exceeds the expected edge, turning a positive-expected-value intent into a negative-EV execution.
Pipeline placement
Applies to: Every OrderIntent — refuses trades whose realistic fee and Polygon gas burden consumes more than the configured fraction
Why it matters
| If this fails | Consequence |
|---|---|
| Fee drag exceeds edge | Placing an order where fees exceed the expected edge results in a systematically negative-EV trade that erodes capital over many repetitions. |
| Gas spike not accounted for | Polygon gas spikes during congestion can materially increase transaction cost; ignoring gas makes fee estimates unreliable during high-traffic periods. |
Inputs
Polymarket inputs
| Input | Source | Required | Use |
|---|---|---|---|
| CLOB fee rate for the target market (operator-set, bps) | clob_public | required | Compute taker or maker fee for the proposed order size and probability. |
| Current Polygon gas price estimate | onchain | required | Estimate the Polygon gas cost for the CTFExchangeV2.matchOrders() settlement transaction. |
| Current market probability (best bid/ask midpoint) | clob_public | required | Compute the fee using the V2 formula: C * feeRate * p * (1-p), which peaks at p=0.5. |
Internal inputs
| Input | Source | Required | Use |
|---|---|---|---|
| Strategy expected edge (bps) per order | internal | required | Compare against the estimated fee-to-notional ratio to enforce the max_fee_to_edge_ratio limit. |
| KillSwitch active flag | KillSwitch | required | If active, reject immediately. |
Authority
What this bot is permitted to do
State
Readiness
Planned
Status
planned
Class
Guardrail
Default mode
planned
Developer owner
Polytraders core — Risk pod
Capital impact
Direct
Reason codes emitted
| Code | Severity | Meaning | Action |
|---|---|---|---|
| KILL_SWITCH_ACTIVE | HARD_REJECT | Global kill switch active. | Immediate HARD_REJECT. |
| FEE_GUARD_COST_EXCEEDS_EDGE | HARD_REJECT | Total cost-to-edge ratio exceeds the hard ceiling. | HARD_REJECT; log total_cost_usd, edge_usd, and ratio. |
| FEE_GUARD_RATE_ANOMALY | HARD_REJECT | Effective fee rate exceeds max_fee_bps (V2 protocol ceiling). | HARD_REJECT; alert on-call — anomalous fee rate detected. |
| FEE_GUARD_ORDER_TOO_SMALL | HARD_REJECT | Order size is below min_order_usd; gas costs dominate. | HARD_REJECT. |
| FEE_GUARD_COST_APPROACHING | WARN | Cost-to-edge ratio between warning and hard threshold. | Attach WARN annotation; APPROVE. |
Related bots in Risk Guardrail
Used by
Reverse index — strategies that currently reference risk.feeandgasguard. If you change this bot's authority or reason codes, these strategies must re-pass shadow.
| Strategy | State | Activity |
|---|---|---|
| US Elections — sentiment fade | demo-wired | last triggered 1m ago |
| BTC weekly — close-aware quotes | demo-wired | last triggered 8m ago |
| Fed Rates — surprise drift | frozen | last triggered 15m ago |
Showing 3 of 3 · demo-wired ≠ production-live
Why this matters
Risk Guardrail bots does NOT propose intents or sign orders; only permits or blocks. Understanding the authority boundary prevents misuse and makes promotion-gate reviews faster and more reliable. View raw spec JSON →