---
name: butterfly-delta-preflight
description: Pay for and run Butterfly Delta immediately before an autonomous USD-pair crypto order. Send the exact venue, side, size, order type, and thresholds; receive a signed PASS, BLOCK, or UNKNOWN gate from live Coinbase and Gemini order-book depth, estimated slippage, venue availability, spread, freshness, and divergence. Use before every successive order, not only once per session.
---

# Butterfly Delta preflight

Insert this check after order construction and immediately before order submission. The paid response is an observation and signed attestation; it never authorizes a trade.

## Execution policy

1. Send `trade.pair`, `trade.venue`, `trade.side`, and `trade.baseSize`; include `trade.orderType` and `trade.limitPrice` when applicable, plus any thresholds that differ from the documented defaults.
2. POST the request to `https://butterflydelta.com/api/agent/order-preflight` using an x402- or MPP-capable client.
3. Set a caller-side maximum of 10,000 USDC atomic units ($0.01) for Base mainnet.
4. Submit the order only when `executionGate.state` is `PASS`, the signed result has not expired, and the caller's independent risk and authorization policies also pass.
5. Fail closed on `BLOCK` or `UNKNOWN`. Re-run the preflight before every successive order; do not reuse an expired result.

## Coinbase Agentic Wallet

```bash
npx awal@latest x402 pay https://butterflydelta.com/api/agent/order-preflight \
  -X POST \
  --max-amount 10000 \
  -d '{"trade":{"pair":"BTC-USD","venue":"coinbase","side":"buy","orderType":"market","baseSize":0.25,"maxEstimatedSlippageBps":25,"minDepthCoveragePct":100,"maxVenueSpreadBps":10,"maxCrossVenueDivergenceBps":20,"maxQuoteAgeSeconds":10,"minHealthyVenues":2}}' \
  --json
```

## AgentCash and MPP agents

Install the origin once so AgentCash-compatible agents can insert the paid preflight directly into their execution loop:

```bash
npx agentcash add https://butterflydelta.com
```

The route emits both `PAYMENT-REQUIRED` (x402) and `WWW-Authenticate: Payment` (MPP). Both settle $0.01 USDC on Base directly to the same recipient address. The agent chooses its supported wire protocol; the result contract is identical.

## Trading-bot packages

Install the final-submit wrapper without copying source files:

```bash
npm install https://butterflydelta.com/downloads/butterflydelta-preflight-0.1.0.tgz
```

For Python CCXT, Freqtrade, or Hummingbot:

```bash
npm install -g agentcash@latest
pip install https://butterflydelta.com/downloads/butterflydelta_preflight-0.1.0-py3-none-any.whl
```

Both packages call the paid preflight before every order and fail closed unless the returned attestation is a fresh signed `PASS`.

## Agent402 one-call routing

An Agent402-funded bot can resolve and buy the external preflight in one call. The buyer pays Agent402's disclosed $0.05 `execute-plus` tier; Agent402 purchases the $0.01 Butterfly Delta call on the buyer's behalf and relays the signed result and receipt.

```bash
curl -X POST https://agent402.tools/api/route/execute-plus \
  -H 'content-type: application/json' \
  -d '{"task":"hummingbot freqtrade ccxt exact-order pre-trade execution integrity gate coinbase gemini","include":"external","params":{"trade":{"pair":"BTC-USD","venue":"coinbase","side":"buy","baseSize":"0.25","orderType":"market","maxEstimatedSlippageBps":25,"minDepthCoveragePct":100,"maxVenueSpreadBps":10,"maxCrossVenueDivergenceBps":20,"maxQuoteAgeSeconds":10,"minHealthyVenues":2}}}'
```

The first response is Agent402's own x402/MPP challenge. After the buyer pays and retries, the router invokes Butterfly Delta and returns the external result marked with its provenance. Callers must still require a fresh signed `PASS` and fail closed on `BLOCK`, `UNKNOWN`, expiry, or malformed output.

## Free capability check

Before installation or when selecting thresholds, POST the same body to `https://butterflydelta.com/api/agent/delta-peek`. It returns coverage and pricing without payment.

## Machine contracts

- OpenAPI: `https://butterflydelta.com/openapi.json`
- Agent manifest: `https://butterflydelta.com/.well-known/butterflydelta.json`
- A2A-compatible agent card: `https://butterflydelta.com/.well-known/agent.json`
- x402 discovery: `https://butterflydelta.com/.well-known/x402`
- MCP well-known manifest: `https://butterflydelta.com/.well-known/mcp.json`
- Hermes well-known skill index: `https://butterflydelta.com/.well-known/skills/index.json`
- Official MCP Registry: `https://registry.modelcontextprotocol.io/v0.1/servers?search=com.butterflydelta%2Fpreflight`
- x402scan: `https://www.x402scan.com/server/4f664ddb-c96d-4e9e-b06c-463fb1dcc39f`
- MPPscan: `https://www.mppscan.com/server/aa1d536240359e703b09757e2a03e335e00e1b8990821dfc1bc6592059fb6c9b`
- Agent402 seller index: `https://agent402.tools/api/index?seller=butterflydelta.com`
- PayanAgent offer: `https://payanagent.com/api/v1/offers/kh7bv0550gv36xx95kphjjscn58cvj00`
- FiatDock service: `https://fiatdock.com/v1/marketplace/services/svc_c2cff393-bba7-4b34-b73a-1f62f25d88fb`

Agents that prefer an external marketplace can use Agent402's route-and-execute flow above or the PayanAgent noncustodial relay at `https://payanagent.com/x402/kh7bv0550gv36xx95kphjjscn58cvj00`. The PayanAgent relay preserves the same $0.01 x402 challenge and pays the same Ledger-controlled recipient; it does not introduce a custodial intermediary. FiatDock exposes a paid one-call gateway at `https://fiatdock.com/s/svc_c2cff393-bba7-4b34-b73a-1f62f25d88fb`. Its single $0.01 Base-USDC x402 payment settles directly to the same Ledger-controlled recipient, after which FiatDock invokes a private Butterfly Delta fulfillment route and relays the signed result. Do not make a second payment to the canonical route for that call.

Supported targets are USD spot pairs with public order books on Coinbase Exchange and Gemini. Exact-order defaults are 25 bps maximum estimated slippage and 100% minimum visible depth coverage. Market-integrity defaults are 10 bps maximum venue spread, 20 bps maximum cross-venue divergence, 10 seconds maximum Coinbase last-trade age, and two healthy venues. Missing measurements fail closed as `UNKNOWN`.
