> ## Documentation Index
> Fetch the complete documentation index at: https://developers.circle.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Fund trades

> Executes funding for trades using Permit2 signatures. This endpoint relays the signed permit data to complete the funding operation for trades.

When `fundingMode` is `delegate`, the request must include the trader's delegate-funding authorization in `permit2`/`signature` along with the funder's permit in `funderPermit2`/`funderSignature`. The funder delivers the tokens on the trader's behalf; no tokens transfer from the trader.




## OpenAPI

````yaml openapi/stablefx.yaml post /v1/exchange/stablefx/fund
openapi: 3.1.0
info:
  title: StableFX API
  description: >
    The StableFX API provides endpoints for trading stablecoins.


    ## Authentication

    All API requests require authentication using an API key.


    ## Base URL

    The base URL for all API endpoints is:
    `https://api.circle.com/v1/exchange/stablefx`
  version: 1.0.0
servers:
  - url: https://api.circle.com
    description: StableFX API server
security:
  - BearerAuth: []
tags:
  - name: Quotes
    description: Endpoints for creating and managing quotes
  - name: Trades
    description: Endpoints for creating and managing trades
  - name: Signatures
    description: Endpoints for retrieving presign typed data and registering signatures
  - name: Fees
    description: Endpoints for retrieving fees
  - name: Funding
    description: Endpoints for funding trades
  - name: Webhook Subscriptions
    description: Manage subscriptions to notifications
  - name: Settlement Advance
    description: Request, track, and repay settlement advances.
paths:
  /v1/exchange/stablefx/fund:
    post:
      tags:
        - Funding
      summary: Fund trades
      description: >
        Executes funding for trades using Permit2 signatures. This endpoint
        relays the signed permit data to complete the funding operation for
        trades.


        When `fundingMode` is `delegate`, the request must include the trader's
        delegate-funding authorization in `permit2`/`signature` along with the
        funder's permit in `funderPermit2`/`funderSignature`. The funder
        delivers the tokens on the trader's behalf; no tokens transfer from the
        trader.
      operationId: fundTrade
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Fund'
      responses:
        '200':
          description: Funding completed successfully
        '400':
          description: Bad request - validation error
      security:
        - BearerAuth: []
components:
  schemas:
    Fund:
      type: object
      description: Request body for funding operations
      required:
        - type
        - signature
        - permit2
      properties:
        type:
          $ref: '#/components/schemas/Type'
        signature:
          type: string
          description: The trader's Permit2 signature over `permit2`
          example: 0x1234567890abcdef...
        fundingMode:
          allOf:
            - $ref: '#/components/schemas/FundingMode'
            - type:
                - string
                - 'null'
          description: The funding mode for the operation (optional)
        permit2:
          oneOf:
            - $ref: '#/components/schemas/Permit2SingleFundingMessage'
            - $ref: '#/components/schemas/Permit2BatchFundingMessage'
            - $ref: '#/components/schemas/DelegateFundingPermit2'
          discriminator:
            propertyName: witness
            mapping:
              SingleTradeWitness:
                $ref: '#/components/schemas/Permit2SingleFundingMessage'
              BatchTradeWitness:
                $ref: '#/components/schemas/Permit2BatchFundingMessage'
              DelegateFundingAuthorization:
                $ref: '#/components/schemas/DelegateFundingPermit2'
          description: >-
            The Permit2 message object signed by the trader. Single or batch
            funding message for `gross`/`net` funding modes; delegate-funding
            authorization (with `permitted.amount` of 0) when `fundingMode` is
            `delegate`.
        funderPermit2:
          allOf:
            - $ref: '#/components/schemas/DelegateFundingFunderPermit2'
          description: >-
            The Permit2 message object signed by the funder, carrying the actual
            delivery amount. Required when `fundingMode` is `delegate`.
        funderSignature:
          type: string
          description: >-
            The funder's Permit2 signature over `funderPermit2`. Required when
            `fundingMode` is `delegate`.
          example: 0xabcdef1234567890...
    Type:
      type: string
      description: The type of trader.
      enum:
        - maker
        - taker
    FundingMode:
      type: string
      description: >
        The funding mode for funding requests.

        - `gross`: the trader delivers the full amount for each trade.

        - `net`: the maker delivers the net difference across trades. Supported
        for maker funding requests only.

        - `delegate`: a funder wallet delivers tokens on the trader's behalf.
        The trader signs a zero-amount Permit2 authorization and the funder
        signs the Permit2 transfer carrying the delivery amount.
      enum:
        - gross
        - net
        - delegate
      default: gross
    Permit2SingleFundingMessage:
      type: object
      description: The message data for Permit2 signature
      required:
        - permitted
        - spender
        - nonce
        - deadline
        - witness
      properties:
        permitted:
          $ref: '#/components/schemas/TokenPermissions'
        spender:
          type: string
          description: The spender contract address
          example: '0xffd21ca8F0876DaFAD7de09404E0c1f868bbf1AE'
        nonce:
          type: string
          description: The nonce for the permit, as a string representation of a uint256
          example: '42'
        deadline:
          type: string
          description: >-
            The deadline timestamp for the permit, as a string representation of
            a uint256
          example: '1735689600'
        witness:
          $ref: '#/components/schemas/SingleTradeWitness'
    Permit2BatchFundingMessage:
      type: object
      description: The message data for Permit2 batch signature
      required:
        - permitted
        - spender
        - nonce
        - deadline
        - witness
      properties:
        permitted:
          type: array
          description: Array of token permissions
          items:
            $ref: '#/components/schemas/TokenPermissions'
          example:
            - token: 0xTOKEN1
              amount: '1000'
            - token: 0xTOKEN2
              amount: '2000'
        spender:
          type: string
          description: The spender contract address
          example: '0xffd21ca8F0876DaFAD7de09404E0c1f868bbf1AE'
        nonce:
          type: string
          description: The nonce for the permit, as a string representation of a uint256
          example: '42'
        deadline:
          type: string
          description: >-
            The deadline timestamp for the permit, as a string representation of
            a uint256
          example: '1735689600'
        witness:
          $ref: '#/components/schemas/BatchTradeWitness'
    DelegateFundingPermit2:
      type: object
      description: >-
        Permit2 PermitWitnessTransferFrom payload with
        DelegateFundingAuthorization witness. The `permitted.amount` is always 0
        -- Permit2 is used as an authorization carrier, no tokens transfer from
        the trader.
      required:
        - permitted
        - spender
        - nonce
        - deadline
        - witness
      properties:
        permitted:
          $ref: '#/components/schemas/TokenPermissions'
        spender:
          type: string
          description: FxEscrow contract address.
          example: 0xFxEscrow000000000000000000000000000000000
        nonce:
          type: string
          description: Permit2 nonce, as a string representation of a uint256.
          example: '1234567890'
        deadline:
          type: string
          description: >-
            Permit2 deadline (unix timestamp), as a string representation of a
            uint256.
          example: '1782556800'
        witness:
          $ref: '#/components/schemas/DelegateFundingAuthorization'
    DelegateFundingFunderPermit2:
      type: object
      description: >-
        Permit2 PermitWitnessTransferFrom payload signed by the funder when
        delivering tokens on a trader's behalf. Unlike the trader's
        authorization payload, this permit carries the actual delivery amount in
        `permitted.amount`. The DelegateFundingWitness binds the funder's
        signature to a specific trade and recipient, and must agree with the
        trader's DelegateFundingAuthorization.
      required:
        - permitted
        - spender
        - nonce
        - deadline
        - witness
      properties:
        permitted:
          $ref: '#/components/schemas/TokenPermissions'
        spender:
          type: string
          description: FxEscrow contract address.
          example: 0xFxEscrow000000000000000000000000000000000
        nonce:
          type: string
          description: Permit2 nonce, as a string representation of a uint256.
          example: '1234567890'
        deadline:
          type: string
          description: >-
            Permit2 deadline (unix timestamp), as a string representation of a
            uint256.
          example: '1782556800'
        witness:
          $ref: '#/components/schemas/DelegateFundingWitness'
    TokenPermissions:
      type: object
      description: Token permissions for Permit2
      required:
        - token
        - amount
      properties:
        token:
          type: string
          description: The token contract address
          example: 0xTOKEN
        amount:
          type: string
          description: >-
            The amount of tokens permitted, as a string representation of a
            uint256.
          example: '1000'
    SingleTradeWitness:
      type: object
      description: Single trade witness data
      required:
        - id
      properties:
        id:
          type: string
          description: The trade ID
          example: '10'
    BatchTradeWitness:
      type: object
      description: Batch trade witness data with multiple IDs
      required:
        - ids
      properties:
        ids:
          type: array
          description: Array of trade IDs
          items:
            type: string
          example:
            - '10'
            - '11'
            - '12'
    DelegateFundingAuthorization:
      type: object
      description: >-
        DelegateFundingAuthorization witness binding the Permit2 authorization
        to a specific trade, funder, recipient, token, and amount.
      required:
        - id
        - funder
        - recipient
        - token
        - amount
      properties:
        id:
          type: string
          description: On-chain trade id (uint256).
          example: '987654321'
        funder:
          type: string
          description: >-
            Address of the funder wallet (Circle-controlled) authorized to
            deliver tokens on the trader's behalf.
          example: 0xLLCFunderPW...address
        recipient:
          type: string
          description: Address that receives the delivered tokens.
          example: 0xLLCEscrowPW...address
        token:
          type: string
          description: ERC-20 contract address of the token to be delivered.
          example: 0xMXNB...address
        amount:
          type: string
          description: >-
            Amount to be delivered by the funder, in token units (uint256, no
            decimals). Tokens use 6 decimal places, so 5000.00 MXNB is
            represented as "5000000000".
          example: '5000000000'
    DelegateFundingWitness:
      type: object
      description: >-
        DelegateFundingWitness signed by the funder when delivering tokens on a
        trader's behalf. Both the trader (via DelegateFundingAuthorization) and
        the funder independently commit to the same recipient, and the contract
        verifies agreement on-chain. The funder address is not part of the
        witness because Permit2 verifies the signer identity via the `owner`
        parameter.
      required:
        - id
        - recipient
      properties:
        id:
          type: string
          description: On-chain trade id (uint256).
          example: '987654321'
        recipient:
          type: string
          description: >-
            Address that receives the delivered tokens. Must match the recipient
            in the trader's DelegateFundingAuthorization.
          example: '0xabcdef1234567890abcdef1234567890abcdef12'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: PREFIX:ID:SECRET
      description: >-
        Circle's API Keys are formatted in the following structure
        "PREFIX:ID:SECRET". All three parts are requred to make a successful
        request.

````