Dflow platform fees

From x402agent/solana-clawd · View interactive version

Dflow platform fees is an AI agent skill from the GitHub repository x402agent/solana-clawd. Monetize a DFlow integration by collecting a builder-defined fee on trades your app routes through the Trade API — either a fixed percentage (spot + PM) via `platformFeeBps`, or a probability-weighted dynamic fee (PM outcome tokens only) via `platformFeeScale`. Use when the user asks "how do I take

How to use this skill

Skill file

DFlow Platform Fees

Collect a fee on trades your app routes through the DFlow Trade API, paid to a builder-controlled token account on successful execution. This is the builder→user fee — builders monetizing their distribution.

Prerequisites

Surface

API only. Platform fees are /order parameters on the Trade API. The dflow CLI is for direct self-trading, not for monetizing a distribution product, so it doesn't expose platform-fee flags — don't hunt for a --platform-fee-bps option.

Which host depends on API-key status, same as the other trading skills: prod https://quote-api.dflow.net with x-api-key, dev https://dev-quote-api.dflow.net.

Two fee models

Pick based on what trades you're fee-ing.

Fixed — `platformFeeBps`

Flat percentage of the trade in basis points (1 bps = 0.01%). platformFeeBps: 50 → 0.5% fee. Works on spot and PM trades. The only option for spot.

Dynamic — `platformFeeScale` (PM outcome tokens only)

Probability-weighted fee that scales with market uncertainty:

fee = k * p * (1 - p) * c

p * (1 - p) peaks at p = 0.5 and is zero at p = 0 / p = 1 — so you charge the most on coin-flip markets, scale down as markets approach certainty, and charge nothing at redemption (p = 1). If your revenue model assumes a take on redemption, rework it.

Example. platformFeeScale = 50, user buys 100 YES contracts at p = 0.40:

fee = 0.050 * 0.40 * 0.60 * 100 = 1.20 → $1.20 on a $40 buy.

Dynamic fees are not available on spot.

Core `/order` parameters

Full param details and encoding → docs MCP, or read the pages directly: CODE0, CODE1.

Mode matrix — who can pay the fee in which token

| Trade type | Allowed platformFeeMode |

|---|---|

| Imperative spot | inputMint or outputMint |

| Declarative spot | outputMint only |

| PM outcome-token trades | Always settlement mint (USDC / CASH), regardless of what you pass |

Easy trap when porting from imperative to declarative: inputMint mode silently becomes invalid.

Fee accounts (ATAs)

You need one ATA per token you collect in. A builder collecting in USDC and SOL needs a USDC ATA and a SOL ATA, both already created, both controlled by the builder's wallet. Pass the relevant one as feeAccount per request — DFlow reads it, validates it matches the mode's token, and transfers on success.

For PM: the fee ATA must be a settlement-mint ATA (USDC or CASH), since that's the only token PM fees can be paid in.

What to ASK the user (and what NOT to ask)

Ask if missing:

  1. Which trade types do you want to collect fees on — spot, PM outcome tokens, or both? Scopes which fee model(s) are relevant: spot-only → platformFeeBps only; PM → either; both → usually platformFeeBps on spot + platformFeeScale on PM (per-request choice).
  2. Rate — bps value for fixed; k value for dynamic.
  3. Collection token(s) — which token(s) do you want the fee paid in, and do you already have a matching ATA owned by the builder wallet?
  4. Imperative or declarative? Only matters for spot and only matters for platformFeeMode — declarative can only fee in outputMint.
  5. DFlow API key. Platform fees are an HTTP-only feature (params on the user's own /order call) — there's no CLI flag for them, so you're always plumbing the key into the script's HTTP client. Ask with a clean, neutral question: "Do you have a DFlow API key?" Don't presuppose where the key lives — phrasings like "do you have it in env?" or "is DFLOW_API_KEY set?" nudge the user toward env-var defaults they didn't ask for. Surface the choice; don't silently fall back to env or to dev. It's one DFlow key everywhere — same x-api-key unlocks Trade API + Metadata API, REST + WebSocket. Yes → prod https://quote-api.dflow.net + x-api-key. No → dev https://dev-quote-api.dflow.net, rate-limited. Pointer: https://pond.dflow.net/build/api-key.

Do NOT ask about:

Gotchas (the docs MCP won't volunteer these)

Platform fees vs DFlow's PM trading fees

Two different things that both use the word "fee":

Don't mix them up when calculating net economics. Platform fees on a spot trade are just a line item between user and builder — DFlow isn't in that loop.

When something doesn't fit

Defer to the docs MCP for exact parameter encoding, the code recipe at CODE0 (runnable, covers both platformFeeBps and platformFeeScale), and the FAQ entries on slippage interaction.

Sibling skills

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.