{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/grainfinance-co/json-schema/grainfinance-co-partner-wallet-schema.json",
  "title": "PartnerWallet",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/grainfinance-co-wallets-api-openapi.yml#/components/schemas/PartnerWallet",
  "properties": {
    "id": {
      "$ref": "#/$defs/UUID",
      "description": "The UUID of the Wallet in Grain's system."
    },
    "totalBalance": {
      "type": "number",
      "format": "double",
      "description": "The current balance, in the wallet currency."
    },
    "availableBalance": {
      "type": "number",
      "format": "double",
      "description": "The available balance (total minus reserved/pending amounts), in the wallet currency."
    },
    "collateralAmount": {
      "type": [
        "number",
        "null"
      ],
      "format": "double",
      "description": "The collateral amount held against open hedges, in the wallet currency."
    },
    "currency": {
      "type": "string",
      "description": "The wallet currency (ISO 4217)"
    },
    "depositDetails": {
      "$ref": "#/$defs/PartnerWalletDepositDetails",
      "description": "Account details for depositing funds to this wallet"
    }
  },
  "required": [
    "id",
    "totalBalance",
    "availableBalance",
    "collateralAmount",
    "currency",
    "depositDetails"
  ],
  "type": "object",
  "additionalProperties": false,
  "$defs": {
    "PartnerWalletDepositDetails": {
      "description": "Bank account details used to deposit funds into a wallet.\nExtends the common base with wallet-specific routing codes (ACH and wire are\nreturned separately for USD wallets, since the same account is reachable via both\nmethods with different routing codes).",
      "properties": {
        "accountHolderName": {
          "type": "string",
          "description": "The full legal name of the account holder."
        },
        "accountNumber": {
          "type": "string",
          "description": "The account number."
        },
        "bankName": {
          "type": "string",
          "description": "The name of the bank holding the account."
        },
        "bankAddress": {
          "type": "string",
          "description": "The full address of the bank."
        },
        "bankCountry": {
          "type": "string",
          "description": "The alpha-2 ISO 3166 country code of the bank.",
          "pattern": "^[A-Za-z]{2}$"
        },
        "bankState": {
          "type": "string",
          "description": "The state/region of the bank's location, when applicable."
        },
        "iban": {
          "type": "string",
          "description": "The IBAN of the account, when applicable.",
          "pattern": "^[A-Z0-9]{15,34}$"
        },
        "bicSwift": {
          "type": "string",
          "description": "The SWIFT/BIC code of the bank, when applicable.",
          "pattern": "^[A-Z]{6}[A-Z0-9]{2}([A-Z0-9]{3})?$"
        },
        "routingCode": {
          "type": "string",
          "description": "Country-specific routing code (e.g. IFSC for India, CLABE for Mexico, Canadian transit), when applicable.\nFor US ACH and wire, see `achRoutingCode` / `wireRoutingCode` on wallet responses."
        },
        "bankCode": {
          "type": "string",
          "description": "Country-specific bank code, when applicable."
        },
        "branchCode": {
          "type": "string",
          "description": "Country-specific branch code, when applicable."
        },
        "sortCode": {
          "type": "string",
          "description": "UK sort code, when applicable. Six digits, no hyphens.",
          "pattern": "^\\d{6}$"
        },
        "bsbCode": {
          "type": "string",
          "description": "Australian BSB code, when applicable. Six digits, no hyphens.",
          "pattern": "^\\d{6}$"
        },
        "specialInstructions": {
          "type": "string",
          "description": "Free-form special instructions associated with this routing, when applicable."
        },
        "achRoutingCode": {
          "type": "string",
          "description": "The ACH routing code of the receiving bank, when applicable.",
          "pattern": "^\\d{9}$"
        },
        "wireRoutingCode": {
          "type": "string",
          "description": "The wire routing code of the receiving bank, when applicable.",
          "pattern": "^\\d{9}$"
        }
      },
      "required": [
        "accountHolderName",
        "accountNumber",
        "bankName",
        "bankAddress",
        "bankCountry"
      ],
      "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}"
    }
  }
}