Skip to main content
BETA - DO NOT USE IN PRODUCTIONThis feature is currently in beta testing. The API and contracts may change without notice. Do not use fee escrow in production applications until this warning is removed.
The Fee Escrow feature allows platforms to collect fees on orders placed through the Order Router. Fees are held in escrow and distributed upon order fills, with automatic refunds on cancellations.
Fee Escrow is an opt-in feature. Orders without fee authorization work exactly as before.

Endpoints Quick Reference

How It Works

Prerequisites

  • @dome-api/sdk version 2.0.0 or later
  • USDC.e approval for the escrow contract on Polygon
  • Platform integration with Dome’s fee system

Quick Start

Using the SDK

Use PolymarketRouterWithEscrow instead of PolymarketRouter:

Skip Escrow for Specific Orders

REST Endpoint

If using the REST API directly, include feeAuth in your request:

Request with Fee Authorization

Response with Escrow Info

Fee Authorization Structure

The feeAuth object contains:

Additional Required Fields

When feeAuth is present, these fields are also required:

EIP-712 Signing

The fee authorization uses EIP-712 typed structured data:

SDK Utilities

The SDK provides utilities for working with fee escrow:

Generate Order ID

Create Fee Authorization

Sign Fee Authorization

Escrow Configuration

Configure escrow settings when initializing the router:

Affiliate Configuration

Affiliates can earn a share of fees collected through the escrow system. There are two ways to configure affiliate addresses:

Option 1: Per-Request (SDK)

Pass the affiliate address when initializing the router or per-order:

Option 2: Server-Side (API Key Config)

For a persistent affiliate address tied to your API key, use the User Settings API. This ensures all orders from your API key automatically use your affiliate address, regardless of what the SDK sends.
Response:

Priority Order

When resolving the affiliate address, the system uses this priority:
  1. Server-side config (from API key settings) - highest priority
  2. Client-provided (from params.affiliate in request)
  3. Default affiliate (environment variable)
  4. Zero address (all fees go to Dome)
Server-side affiliate configuration is recommended for affiliates who want to ensure they always receive their share, as it cannot be overridden by the client.

Error Codes

Fee escrow-specific error codes:

Error Response Example

Escrow Contract

The fee escrow contract is deployed on Polygon mainnet: Address: 0x989876083eD929BE583b8138e40D469ea3E53a37

Contract Functions

USDC Approval

Users must approve the escrow contract to spend their USDC.e:

Fee Distribution

After an order is placed with fee escrow, the Dome server automatically handles fee distribution and refunds based on order status.

How Distribution Works

The server runs a background process that:
  1. Monitors order status - Checks Polymarket for fill status every 5 minutes
  2. Distributes on fill - Calls distribute() when orders are fully or partially filled
  3. Refunds on cancel - Calls refund() when orders are cancelled

Distribution Timing

Partial Fills

For partially filled orders, fees are distributed proportionally:
  • If 50% of an order fills → 50% of fee is distributed
  • Remaining fee stays in escrow until fill or cancel
  • On cancel, remaining fee is refunded to user
Distribution and refund transactions are executed by the Dome operator wallet. Users don’t need to take any action after order placement.

Order Management Endpoints

The following REST endpoints are available for managing escrow orders.

Get Escrow Order

Retrieve details of a specific escrow order by ID (escrowOrderId or polymarketOrderId).
Response:

List Escrow Orders

Retrieve a list of escrow orders with optional filters.
Query Parameters: Response:

Cancel Escrow Order

Cancel an escrow order and initiate a refund. Only callable for orders in pending or open status.
Response:
The POST /orders/:orderId/cancel endpoint is also available for backward compatibility but DELETE /orders/:orderId is preferred.

Order Status Values

Error Responses

Backward Compatibility

Orders without feeAuth work exactly as before:

FAQ

Q: Is fee escrow required? No, it’s opt-in. Orders without feeAuth work normally. Q: What happens if the order is cancelled? The fee is refunded to the payer via the escrow contract. Q: What’s the minimum fee? Fees must meet both requirements:
  • At least 0.01% of order size (to prevent dust)
  • At least $0.01 USDC minimum
Q: How is the affiliate address resolved? When processing an order, the system resolves the affiliate address using this priority (highest first):
  1. Server-side config - Affiliate address set via API key settings (POST /v1/polymarket/affiliate)
  2. Client-provided - affiliateAddress parameter in the order request
  3. Default affiliate - Environment-configured default (if any)
  4. Zero address - If none of the above, all fees go to Dome
Server-side configuration always takes priority, ensuring platforms receive their fee share regardless of what the client sends. Q: How do I become an affiliate? Contact support@domeapi.com to set up affiliate fee sharing. Q: Can I use a different escrow contract? Custom escrow contracts can be configured - contact support for enterprise setups.