{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/grainfinance-co/main/json-schema/grainfinance-co-accept-offline-dual-hedge-proposal-request-body-schema.json",
  "title": "AcceptOfflineDualHedgeProposalRequestBody",
  "description": "The payload required in order to accept an offline rate proposal and book the 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/AcceptOfflineDualHedgeProposalRequestBody",
  "properties": {
    "revision": {
      "type": "number",
      "format": "double",
      "description": "The id of the revision that defines the accepted rate for the currency-pair and tenor."
    },
    "fromCurrency": {
      "$ref": "#/$defs/CurrencyCode",
      "description": "The currency in which the transaction should be paid by your customer."
    },
    "toCurrency": {
      "$ref": "#/$defs/CurrencyCode",
      "description": "The currency you want to buy."
    },
    "customerToCurrencyAmount": {
      "type": "number",
      "format": "double",
      "description": "The amount to hedge in the toCurrency for the customer."
    },
    "vendorToCurrencyAmount": {
      "type": "number",
      "format": "double",
      "description": "The amount to hedge in the toCurrency for the vendor."
    },
    "customerEndAt": {
      "type": "string",
      "description": "The date in which the customer hedge will be settled, denoted in `YYYY-MM-DD` format."
    },
    "vendorEndAt": {
      "type": "string",
      "description": "The date in which the vendor hedge will be settled, denoted in `YYYY-MM-DD` format."
    },
    "rate": {
      "type": "number",
      "format": "double",
      "description": "Represents the offline hedge rate determined by a two-dimensional lookup based on the vendor and customer tenors.\n\n**Calculating Tenors:**\n\nTenors are calculated from the calendar-day difference between the tenorCalculationDate and the vendor/customer end dates, then mapped into the nearest supported tenor bucket:\n\n-\n- > 0 and ≤ 7 calendar days → 7-day tenor\n- > 7 and ≤ 14 calendar days → 14-day tenor\n- > 14 and ≤ 30 calendar days → 30-day tenor\n- > 30 and ≤ 60 calendar days → 60-day tenor\n- > 60 and ≤ 90 calendar days → 90-day tenor\n- … continues in similar ranges up to 720 days\n\n**Note:** All calendar days count — weekends and holidays included.\n\n**Rate Lookup Example:**\n\nThe rate is retrieved from a two-dimensional map using both tenors:\n```\n\"USDMXN\": {\n  \"7\": { \"7\": 1.1 },\n  \"14\": { \"7\": 1.2, \"14\": 1.3 },\n  \"30\": { \"7\": 1.1, \"14\": 1.1, \"30\": 1.1 },\n  // ... and so on\n}\n```\n\nIn this example, if the vendor tenor is 14 days and the customer tenor is 7 days, the rate would be 1.2.\n\nTo calculate the difference in calendar days accurately, we recommend using a date manipulation library, such as date-fns and its `differenceInCalendarDays` function, or a similar feature provided by other date libraries."
    },
    "externalTransactionId": {
      "type": "string",
      "description": "The transaction id, as identified within your system."
    },
    "extraFields": {
      "$ref": "#/$defs/ExtraFieldsParam"
    }
  },
  "required": [
    "revision",
    "fromCurrency",
    "toCurrency",
    "customerToCurrencyAmount",
    "vendorToCurrencyAmount",
    "customerEndAt",
    "vendorEndAt",
    "rate",
    "externalTransactionId"
  ],
  "type": "object",
  "additionalProperties": false,
  "$defs": {
    "CurrencyCode": {
      "type": "string",
      "description": "The alpha-3 ISO 4217 currency code of the related entity, in upper case.",
      "pattern": "^[A-Z]{3}$"
    },
    "ExtraFieldsParam": {
      "properties": {},
      "additionalProperties": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "number",
            "format": "double"
          },
          {
            "type": "boolean"
          }
        ]
      },
      "type": "object",
      "description": "Additional fields that provide further details about the transaction.\nThese fields should be specified as a valid JSON object."
    }
  }
}