{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/cow-protocol/json-schema/cow-protocol-solution-schema.json",
  "title": "Solution",
  "description": "A computed solution for a given auction.\n",
  "x-generated": "2026-10-28",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/solvers.yml#/components/schemas/Solution",
  "type": "object",
  "required": [
    "id",
    "prices",
    "trades",
    "interactions"
  ],
  "properties": {
    "id": {
      "description": "An opaque identifier for the solution. This is a solver generated number that is unique across multiple solutions within the auction.\n",
      "type": "number"
    },
    "prices": {
      "description": "A clearing price map of token address to price. The price can have\narbitrary denomination.\n",
      "type": "object",
      "additionalProperties": {
        "$ref": "#/$defs/U256"
      }
    },
    "trades": {
      "description": "CoW Protocol order trades included in the solution. Each order may\nappear at most once: a partially fillable order can be split across\nmultiple solutions, but not across multiple trades of the same\nsolution. Solutions that violate this are rejected.\n",
      "type": "array",
      "items": {
        "$ref": "#/$defs/Trade"
      }
    },
    "preInteractions": {
      "description": "Interactions to encode before a settlement.\n",
      "type": "array",
      "items": {
        "$ref": "#/$defs/Call"
      }
    },
    "interactions": {
      "description": "Interactions to encode within a settlement.\n",
      "type": "array",
      "items": {
        "$ref": "#/$defs/Interaction"
      }
    },
    "postInteractions": {
      "description": "Interactions to encode after a settlement.\n",
      "type": "array",
      "items": {
        "$ref": "#/$defs/Call"
      }
    },
    "gas": {
      "type": "integer",
      "description": "How many units of gas this solution is estimated to cost."
    },
    "maxFeePerGas": {
      "description": "Optional maximum fee per gas for the settlement transaction.\nOverrides the driver's default gas price estimation.\nMust be provided together with maxPriorityFeePerGas.\nNote: the driver may raise this value if a pending replacement\ntransaction requires a higher gas price.\n",
      "allOf": [
        {
          "$ref": "#/$defs/U256"
        }
      ]
    },
    "maxPriorityFeePerGas": {
      "description": "Optional maximum priority fee (tip) per gas for the settlement\ntransaction. Overrides the driver's default gas price estimation.\nMust be provided together with maxFeePerGas.\nNote: the driver may raise this value if a pending replacement\ntransaction requires a higher gas price.\n",
      "allOf": [
        {
          "$ref": "#/$defs/U256"
        }
      ]
    },
    "flashloans": {
      "description": "Flashloans that are provided for this solution, mapping order UIDs to flashloan details.\nIn case of the field absense, the driver will use the order's flashloan hint originally defined by the user.\n",
      "type": "object",
      "additionalProperties": {
        "$ref": "#/$defs/Flashloan"
      }
    }
  },
  "$defs": {
    "Address": {
      "description": "An Ethereum public address.\n",
      "type": "string"
    },
    "Allowance": {
      "description": "An ERC20 allowance from the settlement contract to some spender that is\nrequired for a custom interaction.\n",
      "type": "object",
      "required": [
        "token",
        "spender",
        "minAmount"
      ],
      "properties": {
        "token": {
          "$ref": "#/$defs/Token"
        },
        "spender": {
          "$ref": "#/$defs/Address"
        },
        "amount": {
          "$ref": "#/$defs/TokenAmount"
        }
      }
    },
    "AppData": {
      "description": "32 bytes of arbitrary application specific data that can be added to an\norder. This can also be used to ensure uniqueness between two orders\nwith otherwise the exact same parameters.\n"
    },
    "Asset": {
      "description": "A token address with an amount.\n",
      "type": "object",
      "required": [
        "token",
        "amount"
      ],
      "properties": {
        "token": {
          "$ref": "#/$defs/Token"
        },
        "amount": {
          "$ref": "#/$defs/TokenAmount"
        }
      }
    },
    "BuyTokenBalance": {
      "description": "Where should the buy token be transferred to?\n\nIn practice only `erc20` occurs: the `internal` (Balancer Vault)\ndestination is rejected at order creation. The value remains for \nbackwards compatibility.\n",
      "type": "string",
      "enum": [
        "erc20",
        "internal"
      ]
    },
    "Call": {
      "type": "object",
      "properties": {
        "target": {
          "$ref": "#/$defs/Address"
        },
        "value": {
          "$ref": "#/$defs/TokenAmount"
        },
        "callData": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/CallData"
          },
          "description": "The call data to be used for the interaction."
        }
      }
    },
    "CallData": {
      "description": "Some `calldata` sent to a contract in a transaction encoded as a hex with `0x` prefix.\n",
      "type": "string"
    },
    "CustomInteraction": {
      "description": "A searcher-specified custom interaction to be included in the final\nsettlement.\n",
      "type": "object",
      "required": [
        "kind",
        "target",
        "value",
        "callData",
        "inputs",
        "outputs"
      ],
      "properties": {
        "kind": {
          "type": "string",
          "enum": [
            "custom"
          ]
        },
        "target": {
          "$ref": "#/$defs/Address"
        },
        "value": {
          "$ref": "#/$defs/TokenAmount"
        },
        "callData": {
          "description": "The EVM calldata bytes.\n",
          "type": "string"
        },
        "allowances": {
          "description": "ERC20 allowances that are required for this custom interaction.\n",
          "type": "array",
          "items": {
            "$ref": "#/$defs/Allowance"
          }
        },
        "inputs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Asset"
          }
        },
        "outputs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Asset"
          }
        }
      }
    },
    "Flashloan": {
      "description": "Contains information about a flashloan for the solver's solution.\n",
      "type": "object",
      "required": [
        "liquidityProvider",
        "protocolAdapter",
        "receiver",
        "token",
        "amount"
      ],
      "properties": {
        "liquidityProvider": {
          "$ref": "#/$defs/Address"
        },
        "protocolAdapter": {
          "$ref": "#/$defs/Address"
        },
        "receiver": {
          "$ref": "#/$defs/Address"
        },
        "token": {
          "$ref": "#/$defs/Token"
        },
        "amount": {
          "$ref": "#/$defs/TokenAmount"
        }
      }
    },
    "Fulfillment": {
      "description": "A trade which fulfills an order from the auction.\n",
      "type": "object",
      "required": [
        "kind",
        "order",
        "executedAmount"
      ],
      "properties": {
        "kind": {
          "type": "string",
          "enum": [
            "fulfillment"
          ]
        },
        "order": {
          "description": "A reference by UID of the order to execute in a solution. The order\nmust be included in the auction input.\n",
          "allOf": [
            {
              "$ref": "#/$defs/OrderUid"
            }
          ]
        },
        "fee": {
          "description": "The sell token amount that should be taken as a fee for this\ntrade. This only gets returned for limit orders and only refers\nto the actual amount filled by the trade.\n"
        },
        "executedAmount": {
          "description": "The amount of the order that was executed. This is denoted in\n\"sellToken\" for sell orders, and \"buyToken\" for buy orders.\n",
          "allOf": [
            {
              "$ref": "#/$defs/TokenAmount"
            }
          ]
        }
      }
    },
    "Interaction": {
      "description": "An interaction to execute as part of a settlement.\n",
      "allOf": [
        {
          "type": "object",
          "properties": {
            "internalize": {
              "description": "A flag indicating that the interaction should be \"internalized\",\nas specified by CIP-2.\n",
              "type": "boolean"
            }
          }
        },
        {
          "oneOf": [
            {
              "$ref": "#/$defs/LiquidityInteraction"
            },
            {
              "$ref": "#/$defs/CustomInteraction"
            }
          ]
        }
      ]
    },
    "JitOrder": {
      "description": "A just-in-time liquidity order included in a settlement. These will\nbe assumed to be fill-or-kill orders with a signed fee of 0.\n",
      "type": "object",
      "required": [
        "sellToken",
        "buyToken",
        "receiver",
        "sellAmount",
        "buyAmount",
        "validTo",
        "appData",
        "kind",
        "sellTokenBalance",
        "buyTokenBalance",
        "signingScheme",
        "signature"
      ],
      "properties": {
        "sellToken": {
          "$ref": "#/$defs/Token"
        },
        "buyToken": {
          "$ref": "#/$defs/Token"
        },
        "receiver": {
          "$ref": "#/$defs/Address"
        },
        "sellAmount": {
          "$ref": "#/$defs/TokenAmount"
        },
        "buyAmount": {
          "$ref": "#/$defs/TokenAmount"
        },
        "validTo": {
          "type": "integer"
        },
        "appData": {
          "$ref": "#/$defs/AppData"
        },
        "kind": {
          "$ref": "#/$defs/OrderKind"
        },
        "partiallyFillable": {
          "type": "boolean"
        },
        "sellTokenBalance": {
          "deprecated": true,
          "allOf": [
            {
              "$ref": "#/$defs/SellTokenBalance"
            }
          ]
        },
        "buyTokenBalance": {
          "deprecated": true,
          "allOf": [
            {
              "$ref": "#/$defs/BuyTokenBalance"
            }
          ]
        },
        "signingScheme": {
          "$ref": "#/$defs/SigningScheme"
        },
        "signature": {
          "$ref": "#/$defs/Signature"
        }
      }
    },
    "JitTrade": {
      "description": "A trade with a JIT order.\n",
      "required": [
        "kind",
        "order",
        "executedAmount",
        "fee"
      ],
      "properties": {
        "kind": {
          "type": "string",
          "enum": [
            "jit"
          ]
        },
        "executedAmount": {
          "description": "The amount of the order that was executed. This is denoted in\n\"sellToken\" for sell orders, and \"buyToken\" for buy orders.\n",
          "allOf": [
            {
              "$ref": "#/$defs/TokenAmount"
            }
          ]
        },
        "fee": {
          "description": "The amount of sell token which should be kept to cover the gas\ncost for this JIT trade. If a fee is set on a sell order the\n\"executedAmount\" needs to be reduced accordingly to not \"overfill\"\nthe order.\n",
          "allOf": [
            {
              "$ref": "#/$defs/TokenAmount"
            }
          ]
        },
        "order": {
          "description": "The just-in-time liquidity order to execute in a solution.\n",
          "allOf": [
            {
              "$ref": "#/$defs/JitOrder"
            }
          ]
        }
      }
    },
    "LiquidityInteraction": {
      "description": "Interaction representing the execution of liquidity that was passed in\nwith the auction.\n",
      "type": "object",
      "required": [
        "kind",
        "id",
        "inputToken",
        "outputToken",
        "inputAmount",
        "outputAmount"
      ],
      "properties": {
        "kind": {
          "type": "string",
          "enum": [
            "liquidity"
          ]
        },
        "id": {
          "description": "The ID of executed liquidity provided in the auction input.\n",
          "type": "number"
        },
        "inputToken": {
          "$ref": "#/$defs/Token"
        },
        "outputToken": {
          "$ref": "#/$defs/Token"
        },
        "inputAmount": {
          "$ref": "#/$defs/TokenAmount"
        },
        "outputAmount": {
          "$ref": "#/$defs/TokenAmount"
        }
      }
    },
    "OrderKind": {
      "description": "The trading side of the order.\n",
      "type": "string",
      "enum": [
        "sell",
        "buy"
      ]
    },
    "OrderUid": {
      "description": "Unique identifier for the order. Order UIDs are 56 bytes long, where\nbytes [0, 32) represent the order digest used for signing, bytes\n[32, 52) represent the owner address and bytes [52, 56) represent the\norder's `validTo` field.\n",
      "type": "string"
    },
    "SellTokenBalance": {
      "description": "Where should the sell token be drawn from?\n\nIn practice only `erc20` occurs: the `internal` and `external` (Balancer\nVault) sources are deprecated and rejected at order creation. The values\nremain for backwards compatibility.\n",
      "type": "string",
      "enum": [
        "erc20",
        "internal",
        "external"
      ]
    },
    "Signature": {
      "description": "Signature bytes.\n",
      "type": "string"
    },
    "SigningScheme": {
      "description": "How was the order signed?\n",
      "type": "string",
      "enum": [
        "eip712",
        "ethSign",
        "preSign",
        "eip1271"
      ]
    },
    "Token": {
      "description": "An ERC20 token address.\n",
      "type": "string"
    },
    "TokenAmount": {
      "description": "Amount of an ERC20 token. 256 bit unsigned integer in decimal notation.\n",
      "type": "string"
    },
    "Trade": {
      "description": "A trade for a CoW Protocol order included in a solution.\n",
      "oneOf": [
        {
          "$ref": "#/$defs/Fulfillment"
        },
        {
          "$ref": "#/$defs/JitTrade"
        }
      ]
    },
    "U256": {
      "description": "256 bit unsigned integer in decimal notation.\n",
      "type": "string"
    }
  }
}