{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/usdf-fi/json-schema/usdf-fi-balance-schema.json",
  "title": "Balance",
  "x-generated": "2026-11-27",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/usdf-fi-openapi.json#/components/schemas/Balance",
  "type": "object",
  "properties": {
    "object": {
      "type": "string",
      "const": "balance"
    },
    "as_of": {
      "type": "string",
      "description": "When it was read.",
      "format": "date-time"
    },
    "scope": {
      "type": "string",
      "description": "key with an API key (available is within its budget), account with a session.",
      "enum": [
        "key",
        "account"
      ]
    },
    "key_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "usdf": {
      "type": "object",
      "description": "Real USDF: what can be spent now, what requests in flight hold, and the balance. Withdrawable as USDF.",
      "properties": {
        "available": {
          "$ref": "#/$defs/Amount"
        },
        "held": {
          "anyOf": [
            {
              "$ref": "#/$defs/Amount"
            },
            {
              "type": "null"
            }
          ]
        },
        "balance": {
          "anyOf": [
            {
              "$ref": "#/$defs/Amount"
            },
            {
              "type": "null"
            }
          ]
        },
        "key_budget_left": {
          "anyOf": [
            {
              "$ref": "#/$defs/Amount"
            },
            {
              "type": "null"
            }
          ]
        },
        "note": {
          "type": "string"
        }
      },
      "required": [
        "available"
      ]
    },
    "wallet": {
      "type": "object",
      "description": "For an account that pays from its own Foundry wallet, read with a session or one of the account's own keys: the wallet's figures, as GET /v1/account/foundry-wallet gives them, each amount in USDF (or USDG) to six decimals. Absent for any other account.",
      "properties": {
        "address": {
          "anyOf": [
            {
              "type": "string",
              "description": "The Foundry wallet's address."
            },
            {
              "type": "null"
            }
          ]
        },
        "usdf_in_wallet": {
          "anyOf": [
            {
              "type": "string",
              "description": "The wallet's USDF; null until the wallet is read."
            },
            {
              "type": "null"
            }
          ]
        },
        "unsettled": {
          "type": "string",
          "description": "What the account used and the wallet has still to pay."
        },
        "credit": {
          "type": "string",
          "description": "What the wallet paid beyond what was used."
        },
        "available": {
          "type": "string",
          "description": "What requests can spend now: the wallet's USDF less what is unsettled and what requests in flight hold."
        },
        "movable": {
          "anyOf": [
            {
              "type": "string",
              "description": "What can be sent, withdrawn or bridged out of the wallet now (a pause or the daily limit leaves it as it is); null until the wallet is read."
            },
            {
              "type": "null"
            }
          ]
        },
        "held": {
          "type": "string",
          "description": "What requests in flight hold."
        },
        "paused": {
          "type": "boolean",
          "description": "Payments from the wallet are paused (pause_reason says why)."
        },
        "pause_reason": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "paying_now": {
          "type": "boolean",
          "description": "A payment from the wallet is due or under way."
        },
        "usdg_in_wallet": {
          "anyOf": [
            {
              "type": "string",
              "description": "The wallet's USDG; null where the chain did not answer."
            },
            {
              "type": "null"
            }
          ]
        },
        "usdg_redeemed_kept": {
          "anyOf": [
            {
              "type": "string",
              "description": "Of that USDG, what a redemption paid in and is kept as USDG; null when not known."
            },
            {
              "type": "null"
            }
          ]
        },
        "converting": {
          "type": "boolean",
          "description": "USDG in the wallet is being converted to USDF."
        },
        "convert_held_until": {
          "anyOf": [
            {
              "type": "string",
              "description": "Until when the conversion waits, where it does."
            },
            {
              "type": "null"
            }
          ]
        },
        "conversion": {
          "anyOf": [
            {
              "type": "object",
              "description": "The latest conversion of the wallet's USDG to USDF: id, amount, status, error, tx_hash, block, created_at, updated_at."
            },
            {
              "type": "null"
            }
          ]
        },
        "conversion_min": {
          "type": "string",
          "description": "The least USDG converted; less stays USDG in the wallet."
        },
        "gas": {
          "type": "object",
          "description": "Who pays the wallet's network fees, and where the wallet does, the ETH in it (eth_in_wallet)."
        },
        "read_at": {
          "anyOf": [
            {
              "type": "string",
              "description": "When the wallet was last read."
            },
            {
              "type": "null"
            }
          ]
        },
        "read_block": {
          "anyOf": [
            {
              "type": "string",
              "description": "The block it was read at."
            },
            {
              "type": "null"
            }
          ]
        },
        "last_paid_at": {
          "anyOf": [
            {
              "type": "string",
              "description": "When the wallet last paid what was used."
            },
            {
              "type": "null"
            }
          ]
        },
        "daily_limit": {
          "type": "object",
          "description": "The wallet's daily limit: the limit in force, the default and the most that may be set, whether it is the account's own, what the wallet paid in the last 24 hours and what is left.",
          "properties": {
            "limit": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "default": {
              "type": "string"
            },
            "max": {
              "type": "string"
            },
            "own": {
              "anyOf": [
                {
                  "type": "boolean"
                },
                {
                  "type": "null"
                }
              ]
            },
            "used_24h": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "left": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "required": [
            "default",
            "max"
          ]
        },
        "note": {
          "type": "string"
        }
      },
      "required": [
        "address",
        "usdf_in_wallet",
        "unsettled",
        "available"
      ]
    },
    "credits": {
      "type": "object",
      "description": "Free credits, as a separate line: not USDF, never withdrawn, sent or redeemed. Each grant shows what is left of it and when it expires.",
      "properties": {
        "ledger": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ]
        },
        "total": {
          "anyOf": [
            {
              "$ref": "#/$defs/Amount"
            },
            {
              "type": "null"
            }
          ]
        },
        "grants": {
          "anyOf": [
            {
              "type": "array",
              "items": {
                "type": "object"
              }
            },
            {
              "type": "null"
            }
          ]
        },
        "note": {
          "type": "string"
        }
      }
    },
    "holder_rewards": {
      "type": "object",
      "description": "The account's USDF Rewards record (USDF Rewards on plain USDF ended at 17:00 UTC on 2 November 2026; plain USDF earns nothing): lifetime_earned, earned_this_hour, last_hour and the rates, as GET /v1/holders/rewards/me gives them. last_week, next_week_estimate, lifetime_usdf and lifetime_units are deprecated.",
      "properties": {
        "program": {
          "type": "string"
        },
        "ledger": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ]
        },
        "lifetime_earned": {
          "$ref": "#/$defs/Amount"
        },
        "claimed": {
          "$ref": "#/$defs/Amount"
        },
        "unclaimed": {
          "$ref": "#/$defs/Amount"
        },
        "earned_this_hour": {
          "type": "object",
          "description": "The amount and per_second: 0, as no hour accrues since the program ended."
        },
        "last_hour": {
          "anyOf": [
            {
              "type": "object",
              "description": "The last accrued hour and what it gave."
            },
            {
              "type": "null"
            }
          ]
        },
        "rates": {
          "anyOf": [
            {
              "type": "object",
              "description": "The newest rate per USDF per hour, and annualized."
            },
            {
              "type": "null"
            }
          ]
        },
        "claim": {
          "type": "object",
          "description": "Only while payouts are not sent on their own: where to claim, and the least claimed.",
          "properties": {
            "endpoint": {
              "type": "string"
            },
            "min": {
              "anyOf": [
                {
                  "$ref": "#/$defs/Amount"
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "required": [
            "endpoint"
          ]
        },
        "wallet": {
          "anyOf": [
            {
              "type": "string",
              "description": "The linked wallet's own record: GET /v1/holders/rewards/{address}."
            },
            {
              "type": "null"
            }
          ]
        },
        "deprecated": {
          "type": "array",
          "description": "The fields kept for earlier readers: last_week, next_week_estimate, lifetime_usdf, lifetime_units.",
          "items": {
            "type": "string"
          }
        },
        "last_week": {
          "anyOf": [
            {
              "type": "object"
            },
            {
              "type": "null"
            }
          ]
        },
        "next_week_estimate": {
          "anyOf": [
            {
              "type": "object"
            },
            {
              "type": "null"
            }
          ]
        },
        "lifetime_usdf": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "lifetime_units": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "note": {
          "type": "string"
        }
      }
    },
    "note": {
      "type": "string"
    }
  },
  "required": [
    "object",
    "usdf",
    "credits",
    "holder_rewards"
  ],
  "$defs": {
    "Amount": {
      "type": "object",
      "description": "An amount of USDF: base units (1 unit = 0.000001 USDF) as a decimal string, with the same amount in USDF (and in dollars, 1 USDF = $1 of compute).",
      "properties": {
        "units": {
          "type": "string",
          "description": "USDF base units.",
          "pattern": "^-?[0-9]+$"
        },
        "usdf": {
          "type": "string",
          "description": "The amount in USDF, to six decimals."
        },
        "usd": {
          "type": "string",
          "description": "The amount in dollars."
        }
      },
      "required": [
        "units"
      ]
    }
  }
}