{
  "$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-hedge-proposal-request-body-schema.json",
  "title": "AcceptOfflineHedgeProposalRequestBody",
  "description": "The payload required in order to accept an offline rate proposal and book the hedge.",
  "x-generated": "2026-10-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/grainfinance-co-openapi.yaml#/components/schemas/AcceptOfflineHedgeProposalRequestBody",
  "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 at by your customer."
    },
    "toCurrency": {
      "$ref": "#/$defs/CurrencyCode",
      "description": "the currency you want to buy."
    },
    "toCurrencyAmount": {
      "type": "number",
      "format": "double",
      "description": "The amount to hedge in the toCurrency."
    },
    "endAt": {
      "$ref": "#/$defs/GrainDateFormat",
      "description": "The date in which the hedge will be settled, denoted in `YYYY-MM-DD` format."
    },
    "rate": {
      "type": "number",
      "format": "double",
      "description": "Represents the exchange rate according to the offline map of currency pairs to tenor object.\n\nThe calculation of the tenor is based on the difference in calendar days between the 'tenorCalculationDate' and the 'endAt' date:\n\n- If the number of calendar days from 'tenorCalculationDate' to `endAt` is less than or equal to 7, the tenor is 7 days.\n- If the number of calendar days from 'tenorCalculationDate' to `endAt` is greater than 7 and less than or equal to 14, the tenor is 14 days.\n- If the number of calendar days from 'tenorCalculationDate' to `endAt` is greater than 14 and less than or equal to 30, the tenor is 30 days.\n- If the number of calendar days from 'tenorCalculationDate' to `endAt` is greater than 30 and less than or equal to 60, the tenor is 60 days.\n- ...\n- If the number of calendar days from 'tenorCalculationDate' to `endAt` is greater than 330 and less than or equal to 360, the tenor is 360 days.\n\nWhen counting the difference in calendar days, every day is counted as one regardless of the duration of the day. This means that the calculation includes all days: weekends, holidays, and weekdays alike.\n\nFor example, if the 'endAt' date is 2023-12-16 and the 'tenorCalculationDate' is 2024-12-15, the result is 1 calendar day.\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": "Optional The transaction id, as identified within your system."
    },
    "extraFields": {
      "$ref": "#/$defs/ExtraFieldsParam"
    }
  },
  "required": [
    "revision",
    "fromCurrency",
    "toCurrency",
    "toCurrencyAmount",
    "endAt",
    "rate"
  ],
  "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."
    },
    "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}"
    }
  }
}