{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/grainfinance-co/main/json-schema/grainfinance-co-get-dual-hedge-response-body-schema.json",
  "title": "GetDualHedgeResponseBody",
  "description": "The response for retrieving a dual hedge.",
  "x-generated": "2026-10-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/grainfinance-co-openapi.yaml#/components/schemas/GetDualHedgeResponseBody",
  "properties": {
    "id": {
      "$ref": "#/$defs/UUID",
      "description": "The id of the dual hedge within the Grain platform."
    },
    "issuedAt": {
      "$ref": "#/$defs/GrainDateFormat",
      "description": "The date in which the hedge was issued, denoted in `YYYY-MM-DD` format."
    },
    "customerId": {
      "$ref": "#/$defs/UUID",
      "description": "The id of the customer within the Grain platform."
    },
    "functionalCurrency": {
      "type": "string",
      "description": "The functional currency of the customer."
    },
    "fromCurrency": {
      "type": "string",
      "description": "The currency in which the transaction should be paid by your customer."
    },
    "toCurrency": {
      "type": "string",
      "description": "The currency you want to buy."
    },
    "rate": {
      "type": "number",
      "format": "double",
      "description": "Represents the offline hedge rate determined by a two-dimensional lookup based on the vendor and customer tenors."
    },
    "hedges": {
      "items": {
        "$ref": "#/$defs/DualHedgeCustomerHedge"
      },
      "type": "array",
      "description": "The individual hedges that make up this dual hedge."
    }
  },
  "required": [
    "id",
    "issuedAt",
    "customerId",
    "functionalCurrency",
    "fromCurrency",
    "toCurrency",
    "rate",
    "hedges"
  ],
  "type": "object",
  "additionalProperties": false,
  "$defs": {
    "CollectionHedge": {
      "properties": {
        "id": {
          "$ref": "#/$defs/UUID",
          "description": "The id of the hedge within the Grain platform."
        },
        "customerId": {
          "$ref": "#/$defs/UUID",
          "description": "The id of the customer within the Grain platform."
        },
        "status": {
          "$ref": "#/$defs/DisplayHedgeStatus",
          "description": "The Status of the Hedge"
        },
        "contractType": {
          "anyOf": [
            {
              "$ref": "#/$defs/HedgeContractType.Flexible"
            },
            {
              "$ref": "#/$defs/HedgeContractType.Standard"
            }
          ],
          "description": "The contract type of the hedge. Returned only for flexible and standard hedges."
        },
        "fixedSide": {
          "$ref": "#/$defs/DisplayFixedSide",
          "description": "Indicates which currency amount was fixed (specified) when creating the hedge.\nWhen `fixedSide` is `toCurrencyAmount`, the `toCurrencyAmount` was specified and `fromCurrencyAmount` was calculated.\nWhen `fixedSide` is `fromCurrencyAmount`, the `fromCurrencyAmount` was specified and `toCurrencyAmount` was calculated."
        },
        "transactionId": {
          "$ref": "#/$defs/UUID",
          "description": "The id of the transaction within the Grain platform."
        },
        "externalTransactionId": {
          "type": "string",
          "description": "The transaction id as identified within your system."
        },
        "externalCustomerId": {
          "type": "string",
          "description": "The id used to identify the customer within your platform"
        },
        "fromCurrency": {
          "type": "string",
          "description": "The currency in which the transaction should be paid at by your customer."
        },
        "toCurrency": {
          "type": "string",
          "description": "The currency in which the inventory item is listed at on your platform."
        },
        "settlementType": {
          "$ref": "#/$defs/DisplaySettlementType.Full",
          "description": "The method in which the hedge is being settled.\nIf 'full' type is set, the total hedge amount should be sent to Grain prior to settlement"
        },
        "originalFromCurrencyAmount": {
          "type": "number",
          "format": "double",
          "description": "The `fromCurrencyAmount` the hedge was originally booked with, before any amendment.\nReturned only for flexible and standard hedges."
        },
        "originalToCurrencyAmount": {
          "type": "number",
          "format": "double",
          "description": "The `toCurrencyAmount` the hedge was originally booked with, before any amendment.\nReturned only for flexible and standard hedges."
        },
        "originalQuote": {
          "type": "number",
          "format": "double",
          "description": "The rate the hedge was originally booked with, before any amendment.\nReturned only for flexible and standard hedges."
        },
        "originalEndAt": {
          "$ref": "#/$defs/GrainDateFormat",
          "description": "The settlement date the hedge was originally booked with, before any amendment,\ndenoted in `YYYY-MM-DD` format. Returned only for flexible and standard hedges."
        },
        "initialCollateralAmount": {
          "type": "number",
          "format": "double",
          "description": "The initial collateral amount required for this hedge in the fromCurrency.\nCalculated as fromCurrencyAmount * initialCollateralPercentage."
        },
        "quote": {
          "type": "number",
          "format": "double",
          "description": "The rate locked by this hedge."
        },
        "externalMarkupPct": {
          "type": [
            "number",
            "null"
          ],
          "format": "double",
          "description": "The external markup percentage that should be added to this quote on top of Grain’s internal pricing.\nFor example, a value of 1.0 represents a 1.0% additional markup."
        },
        "issuedAt": {
          "$ref": "#/$defs/GrainDateFormat",
          "description": "The date in which the hedge was issued, denoted in `YYYY-MM-DD` format."
        },
        "acceptedAtTs": {
          "type": "number",
          "format": "double",
          "description": "The unix timestamp in which the hedge offer was accepted (if it was)."
        },
        "fromCurrencyAmount": {
          "type": "number",
          "format": "double",
          "description": "The amount to hedge in the fromCurrency.\nIf toCurrencyAmount is provided, then fromCurrencyAmount calculated as:\n`fromCurrencyAmount = toCurrencyAmount * quote`"
        },
        "toCurrencyAmount": {
          "type": "number",
          "format": "double",
          "description": "The amount to hedge in the toCurrency.\nIf fromCurrencyAmount is provided, then toCurrencyAmount calculated as:\n`toCurrencyAmount = fromCurrencyAmount / quote`"
        },
        "collateralAmount": {
          "type": "number",
          "format": "double",
          "description": "Current remaining collateral — shrinks with each drawdown, distinct from\ninitialCollateralAmount, which never changes."
        },
        "totalNumberOfDrawdowns": {
          "type": "number",
          "format": "double",
          "description": "Total number of drawdowns created against this hedge, across all statuses except Failed.\nReturned only for flexible and standard hedges."
        },
        "endAt": {
          "$ref": "#/$defs/GrainDateFormat",
          "description": "The date in which the hedge will be settled, denoted in `YYYY-MM-DD` format."
        },
        "settlementAt": {
          "$ref": "#/$defs/GrainDateFormat",
          "description": "The date in which the hedge begins settlement, denoted in `YYYY-MM-DD` format."
        },
        "updatedAt": {
          "$ref": "#/$defs/GrainDateFormat",
          "description": "The date in which the hedge was last modified, denoted in `YYYY-MM-DD` format."
        },
        "cancelledAt": {
          "description": "The date in which the hedge was cancelled, denoted in `YYYY-MM-DD` format.",
          "oneOf": [
            {
              "$ref": "#/$defs/GrainDateFormat"
            },
            {
              "type": "null"
            }
          ]
        },
        "initialCollateralReceivedAt": {
          "description": "The date in which the initial collateral was received, denoted in `YYYY-MM-DD` format.\nNull if not yet received.",
          "oneOf": [
            {
              "$ref": "#/$defs/GrainDateFormat"
            },
            {
              "type": "null"
            }
          ]
        },
        "fundsReceivedAt": {
          "description": "The date in which the funds of the hedge arrived, afterwards the settlement occurs denoted in `YYYY-MM-DD` format.",
          "oneOf": [
            {
              "$ref": "#/$defs/GrainDateFormat"
            },
            {
              "type": "null"
            }
          ]
        },
        "completedAt": {
          "description": "The date in which the hedge was completed, denoted in `YYYY-MM-DD` format.",
          "oneOf": [
            {
              "$ref": "#/$defs/GrainDateFormat"
            },
            {
              "type": "null"
            }
          ]
        },
        "completedAtTs": {
          "type": [
            "number",
            "null"
          ],
          "format": "double",
          "description": "The unix timestamp in which the hedge was completed."
        },
        "overdueAt": {
          "$ref": "#/$defs/GrainDateFormat",
          "description": "The date in which the hedge will become overdue, denoted in `YYYY-MM-DD` format."
        },
        "adjustedMtmChangePct": {
          "type": [
            "number",
            "null"
          ],
          "format": "double",
          "description": "The percentage change in the adjusted mark-to-market value since the previous valuation.\nA value of 1.0 represents a 1.0% change. A negative value indicates a potential margin call if the threshold has been exceeded."
        },
        "adjustedMtmChangeTs": {
          "type": [
            "number",
            "null"
          ],
          "format": "double",
          "description": "The timestamp at which the latest adjusted mark-to-market change was calculated."
        }
      },
      "required": [
        "id",
        "customerId",
        "status",
        "fixedSide",
        "transactionId",
        "externalTransactionId",
        "externalCustomerId",
        "fromCurrency",
        "toCurrency",
        "settlementType",
        "initialCollateralAmount",
        "quote",
        "externalMarkupPct",
        "issuedAt",
        "acceptedAtTs",
        "fromCurrencyAmount",
        "toCurrencyAmount",
        "endAt",
        "settlementAt",
        "updatedAt",
        "cancelledAt",
        "initialCollateralReceivedAt",
        "fundsReceivedAt",
        "completedAt",
        "completedAtTs",
        "overdueAt",
        "adjustedMtmChangePct",
        "adjustedMtmChangeTs"
      ],
      "type": "object",
      "additionalProperties": false
    },
    "CustomerHedge": {
      "anyOf": [
        {
          "$ref": "#/$defs/CollectionHedge"
        },
        {
          "$ref": "#/$defs/OffsetHedge"
        }
      ],
      "description": "Hedge objects represent transactions which are currently hedged."
    },
    "DisplayFixedSide": {
      "description": "The fixed side as displayed in external APIs (camelCase format).\nIndicates which currency amount was specified when creating the hedge.",
      "enum": [
        "toCurrencyAmount",
        "fromCurrencyAmount"
      ],
      "type": "string"
    },
    "DisplayHedgeStatus": {
      "description": "The status of a hedge as displayed in the Partners API.\nMirrors the internal hedge statuses that are exposed to partners; the internal\nterminal `Terminated` status is intentionally omitted, as terminated hedges are\nnever returned by the Partners API.",
      "enum": [
        "Active",
        "Cancelled",
        "Completed",
        "InProcess",
        "Overdue"
      ],
      "type": "string"
    },
    "DisplaySettlementType.Full": {
      "enum": [
        "full"
      ],
      "type": "string"
    },
    "DisplaySettlementType.Offset": {
      "enum": [
        "offset"
      ],
      "type": "string"
    },
    "DualHedgeCustomerHedge": {
      "allOf": [
        {
          "$ref": "#/$defs/CustomerHedge"
        },
        {
          "properties": {
            "spotRate": {
              "type": "number",
              "format": "double"
            }
          },
          "required": [
            "spotRate"
          ],
          "type": "object"
        }
      ],
      "description": "Hedge objects represent transactions which are currently hedged."
    },
    "GrainDateFormat": {
      "type": "string",
      "format": "YYYY-MM-DD",
      "description": "The date format accepted by Grain's API. We accept dash separated ISO-8601 date-only strings.",
      "pattern": "\\d{4}-\\d{2}-\\d{2}"
    },
    "HedgeContractType.Flexible": {
      "enum": [
        "flexible"
      ],
      "type": "string"
    },
    "HedgeContractType.Standard": {
      "enum": [
        "standard"
      ],
      "type": "string"
    },
    "OffsetHedge": {
      "properties": {
        "id": {
          "$ref": "#/$defs/UUID",
          "description": "The id of the hedge within the Grain platform."
        },
        "customerId": {
          "$ref": "#/$defs/UUID",
          "description": "The id of the customer within the Grain platform."
        },
        "status": {
          "$ref": "#/$defs/DisplayHedgeStatus",
          "description": "The Status of the Hedge"
        },
        "contractType": {
          "anyOf": [
            {
              "$ref": "#/$defs/HedgeContractType.Flexible"
            },
            {
              "$ref": "#/$defs/HedgeContractType.Standard"
            }
          ],
          "description": "The contract type of the hedge. Returned only for flexible and standard hedges."
        },
        "fixedSide": {
          "$ref": "#/$defs/DisplayFixedSide",
          "description": "Indicates which currency amount was fixed (specified) when creating the hedge.\nWhen `fixedSide` is `toCurrencyAmount`, the `toCurrencyAmount` was specified and `fromCurrencyAmount` was calculated.\nWhen `fixedSide` is `fromCurrencyAmount`, the `fromCurrencyAmount` was specified and `toCurrencyAmount` was calculated."
        },
        "transactionId": {
          "$ref": "#/$defs/UUID",
          "description": "The id of the transaction within the Grain platform."
        },
        "externalTransactionId": {
          "type": "string",
          "description": "The transaction id as identified within your system."
        },
        "externalCustomerId": {
          "type": "string",
          "description": "The id used to identify the customer within your platform"
        },
        "fromCurrency": {
          "type": "string",
          "description": "The currency in which the transaction should be paid at by your customer."
        },
        "toCurrency": {
          "type": "string",
          "description": "The currency in which the inventory item is listed at on your platform."
        },
        "settlementType": {
          "$ref": "#/$defs/DisplaySettlementType.Offset",
          "description": "The method in which the hedge is being settled.\nIf 'offset' type is set, only the difference between the locked rate and settlement rate is exchanged"
        },
        "originalFromCurrencyAmount": {
          "type": "number",
          "format": "double",
          "description": "The `fromCurrencyAmount` the hedge was originally booked with, before any amendment.\nReturned only for flexible and standard hedges."
        },
        "originalToCurrencyAmount": {
          "type": "number",
          "format": "double",
          "description": "The `toCurrencyAmount` the hedge was originally booked with, before any amendment.\nReturned only for flexible and standard hedges."
        },
        "originalQuote": {
          "type": "number",
          "format": "double",
          "description": "The rate the hedge was originally booked with, before any amendment.\nReturned only for flexible and standard hedges."
        },
        "originalEndAt": {
          "$ref": "#/$defs/GrainDateFormat",
          "description": "The settlement date the hedge was originally booked with, before any amendment,\ndenoted in `YYYY-MM-DD` format. Returned only for flexible and standard hedges."
        },
        "initialCollateralAmount": {
          "type": "number",
          "format": "double",
          "description": "The initial collateral amount required for this hedge in the fromCurrency.\nCalculated as fromCurrencyAmount * initialCollateralPercentage."
        },
        "quote": {
          "type": "number",
          "format": "double",
          "description": "The rate locked by this hedge."
        },
        "externalMarkupPct": {
          "type": [
            "number",
            "null"
          ],
          "format": "double",
          "description": "The external markup percentage that should be added to this quote on top of Grain’s internal pricing.\nFor example, a value of 1.0 represents a 1.0% additional markup."
        },
        "issuedAt": {
          "$ref": "#/$defs/GrainDateFormat",
          "description": "The date in which the hedge was issued, denoted in `YYYY-MM-DD` format."
        },
        "acceptedAtTs": {
          "type": "number",
          "format": "double",
          "description": "The unix timestamp in which the hedge offer was accepted (if it was)."
        },
        "fromCurrencyAmount": {
          "type": "number",
          "format": "double",
          "description": "The amount to hedge in the fromCurrency.\nIf toCurrencyAmount is provided, then fromCurrencyAmount calculated as:\n`fromCurrencyAmount = toCurrencyAmount * quote`"
        },
        "toCurrencyAmount": {
          "type": "number",
          "format": "double",
          "description": "The amount to hedge in the toCurrency.\nIf fromCurrencyAmount is provided, then toCurrencyAmount calculated as:\n`toCurrencyAmount = fromCurrencyAmount / quote`"
        },
        "collateralAmount": {
          "type": "number",
          "format": "double",
          "description": "Current remaining collateral — shrinks with each drawdown, distinct from\ninitialCollateralAmount, which never changes."
        },
        "totalNumberOfDrawdowns": {
          "type": "number",
          "format": "double",
          "description": "Total number of drawdowns created against this hedge, across all statuses except Failed.\nReturned only for flexible and standard hedges."
        },
        "endAt": {
          "$ref": "#/$defs/GrainDateFormat",
          "description": "The date in which the hedge will be settled, denoted in `YYYY-MM-DD` format."
        },
        "settlementAt": {
          "$ref": "#/$defs/GrainDateFormat",
          "description": "The date in which the hedge begins settlement, denoted in `YYYY-MM-DD` format."
        },
        "updatedAt": {
          "$ref": "#/$defs/GrainDateFormat",
          "description": "The date in which the hedge was last modified, denoted in `YYYY-MM-DD` format."
        },
        "cancelledAt": {
          "description": "The date in which the hedge was cancelled, denoted in `YYYY-MM-DD` format.",
          "oneOf": [
            {
              "$ref": "#/$defs/GrainDateFormat"
            },
            {
              "type": "null"
            }
          ]
        },
        "initialCollateralReceivedAt": {
          "description": "The date in which the initial collateral was received, denoted in `YYYY-MM-DD` format.\nNull if not yet received.",
          "oneOf": [
            {
              "$ref": "#/$defs/GrainDateFormat"
            },
            {
              "type": "null"
            }
          ]
        },
        "fundsReceivedAt": {
          "description": "The date in which the funds of the hedge arrived, afterwards the settlement occurs denoted in `YYYY-MM-DD` format.",
          "oneOf": [
            {
              "$ref": "#/$defs/GrainDateFormat"
            },
            {
              "type": "null"
            }
          ]
        },
        "completedAt": {
          "description": "The date in which the hedge was completed, denoted in `YYYY-MM-DD` format.",
          "oneOf": [
            {
              "$ref": "#/$defs/GrainDateFormat"
            },
            {
              "type": "null"
            }
          ]
        },
        "completedAtTs": {
          "type": [
            "number",
            "null"
          ],
          "format": "double",
          "description": "The unix timestamp in which the hedge was completed."
        },
        "overdueAt": {
          "$ref": "#/$defs/GrainDateFormat",
          "description": "The date in which the hedge will become overdue, denoted in `YYYY-MM-DD` format."
        },
        "adjustedMtmChangePct": {
          "type": [
            "number",
            "null"
          ],
          "format": "double",
          "description": "The percentage change in the adjusted mark-to-market value since the previous valuation.\nA value of 1.0 represents a 1.0% change. A negative value indicates a potential margin call if the threshold has been exceeded."
        },
        "adjustedMtmChangeTs": {
          "type": [
            "number",
            "null"
          ],
          "format": "double",
          "description": "The timestamp at which the latest adjusted mark-to-market change was calculated."
        },
        "settlementAmount": {
          "type": "number",
          "format": "double",
          "description": "The total amount settled for the hedge. The amount can be positive or negative"
        },
        "settlementCurrency": {
          "type": "string",
          "description": "The currency in which the settlement was processed"
        },
        "endDateQuote": {
          "type": "number",
          "format": "double",
          "description": "The rate used to calculate the hedge settlement amount"
        }
      },
      "required": [
        "id",
        "customerId",
        "status",
        "fixedSide",
        "transactionId",
        "externalTransactionId",
        "externalCustomerId",
        "fromCurrency",
        "toCurrency",
        "settlementType",
        "initialCollateralAmount",
        "quote",
        "externalMarkupPct",
        "issuedAt",
        "acceptedAtTs",
        "fromCurrencyAmount",
        "toCurrencyAmount",
        "endAt",
        "settlementAt",
        "updatedAt",
        "cancelledAt",
        "initialCollateralReceivedAt",
        "fundsReceivedAt",
        "completedAt",
        "completedAtTs",
        "overdueAt",
        "adjustedMtmChangePct",
        "adjustedMtmChangeTs"
      ],
      "type": "object",
      "additionalProperties": false
    },
    "UUID": {
      "type": "string",
      "format": "uuid",
      "pattern": "[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-4[0-9A-Fa-f]{3}-[89ABab][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}"
    }
  }
}