{
  "openapi": "3.1.0",
  "info": {
    "title": "Loopscale API",
    "version": "0.1.0"
  },
  "servers": [
    {
      "url": "https://tars.loopscale.com/v1",
      "description": "Loopscale Production Server"
    }
  ],
  "paths": {
    "/markets/lending_vaults/info": {
      "post": {
        "tags": [
          "lending_vaults_data"
        ],
        "summary": "Get Loopscale Vaults",
        "description": "Returns a list of raw Vault metadata and data that match filters.",
        "operationId": "query_get_lending_vaults",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FetchLendVaultsInfoParams"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "List of Vaults that match filter",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LendVaultsInfoResponse"
                }
              }
            }
          },
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AssetTerms": {
        "type": "object",
        "required": [
          "durationAndApys",
          "allocationInfo"
        ],
        "properties": {
          "allocationInfo": {
            "$ref": "#/components/schemas/ParsedCollateralCaps"
          },
          "durationAndApys": {
            "type": "array",
            "items": {},
            "description": "Positional `[duration, apy]` pairs — a heterogeneous 2-tuple array, so it's\ntyped as an array of JSON values rather than a named element type."
          }
        }
      },
      "ErrorDetails": {
        "type": "object",
        "description": "Inner detail of the [`ErrorResponse`] envelope.",
        "required": [
          "code",
          "message"
        ],
        "properties": {
          "code": {
            "type": "integer",
            "format": "int32",
            "description": "HTTP status code, mirrored in the response status line",
            "example": 400,
            "minimum": 0
          },
          "message": {
            "type": "string",
            "description": "human-readable, client-safe message (sensitive data redacted)",
            "example": "Request could not be processed."
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "description": "Canonical error envelope for every endpoint. The `x-request-id` response\nheader carries the correlation id for the failing request.",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "$ref": "#/components/schemas/ErrorDetails",
            "description": "error detail"
          }
        }
      },
      "ExternalYieldInfo": {
        "type": "object",
        "required": [
          "externalYieldSource",
          "balance",
          "apy",
          "yieldAccount",
          "lastUpdateTime"
        ],
        "properties": {
          "apy": {
            "type": "string"
          },
          "balance": {
            "type": "string"
          },
          "externalYieldSource": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "lastUpdateTime": {
            "type": "integer",
            "format": "int64"
          },
          "yieldAccount": {
            "type": "string"
          }
        }
      },
      "FetchLendVaultsInfoParams": {
        "type": "object",
        "required": [
          "page",
          "pageSize"
        ],
        "properties": {
          "depositsEnabled": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "featured": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "includeRewards": {
            "type": "boolean"
          },
          "includeStrategySummaries": {
            "type": "boolean",
            "description": "When true, enrich each returned vault with `strategySummary` (the same\nper-strategy USD/APY numbers as `POST /strategy/summaries`), letting the\nFE render APY/TVL without a second call."
          },
          "lpMints": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "mintEnabled": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "page": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "pageSize": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "principalMints": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sortDirection": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "sortType": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "vaultAddresses": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "vaultIdentifiers": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "LendingVaultInfo": {
        "type": "object",
        "required": [
          "vault",
          "vaultStrategy",
          "vaultRewardsSchedules"
        ],
        "properties": {
          "strategySummary": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/StrategyInfoUsdFields",
                "description": "Strategy's USD/APY summary (TVL, deployed, blended APY, …), populated only\nwhen `/lending_vaults/info` is called with `includeStrategySummaries`."
              }
            ]
          },
          "totalOutstandingLoanCollateralValueUsd": {
            "type": "number",
            "format": "double"
          },
          "vault": {
            "$ref": "#/components/schemas/ParsedLendingVault"
          },
          "vaultMetadata": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/LendingVaultMetadata",
                "description": "Off-chain vault metadata."
              }
            ]
          },
          "vaultRewardsEmittedAmounts": {
            "type": [
              "object",
              "null"
            ],
            "description": "Map of schedule index (as string) → emitted amount (claimed + pending across active stakes).",
            "additionalProperties": {
              "type": "integer",
              "format": "int64",
              "minimum": 0
            },
            "propertyNames": {
              "type": "string"
            }
          },
          "vaultRewardsSchedules": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ParsedVaultRewardsSchedule"
            },
            "description": "Active rewards schedules."
          },
          "vaultStrategy": {
            "$ref": "#/components/schemas/StrategyInfo",
            "description": "Underlying strategy info."
          }
        }
      },
      "LendingVaultMetadata": {
        "type": "object",
        "description": "Off-chain vault display/product metadata.",
        "required": [
          "name",
          "description",
          "managerName",
          "managerImage"
        ],
        "properties": {
          "bannerImage": {
            "type": [
              "string",
              "null"
            ]
          },
          "comingSoonBanner": {
            "type": [
              "string",
              "null"
            ]
          },
          "depositCap": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "minimum": 0
          },
          "description": {
            "type": "string"
          },
          "managerImage": {
            "type": "string"
          },
          "managerName": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "notifyFormUrl": {
            "type": [
              "string",
              "null"
            ]
          },
          "tags": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            }
          },
          "themeColor": {
            "type": [
              "string",
              "null"
            ]
          },
          "tokenImage": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "LendVaultsInfoResponse": {
        "type": "object",
        "required": [
          "lendVaults",
          "total"
        ],
        "properties": {
          "hasMore": {
            "type": "boolean",
            "description": "Whether more vaults exist beyond the current page."
          },
          "lendVaults": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LendingVaultInfo"
            }
          },
          "total": {
            "type": "integer",
            "format": "int64",
            "description": "Total matched vaults across the full filter (not page-scoped).",
            "minimum": 0
          }
        }
      },
      "ParsedCapMonitor": {
        "type": "object",
        "required": [
          "startTime1hr",
          "startTime24hr",
          "principal1hr",
          "principal24hr"
        ],
        "properties": {
          "principal1hr": {
            "type": "string"
          },
          "principal24hr": {
            "type": "string"
          },
          "startTime1hr": {
            "type": "string"
          },
          "startTime24hr": {
            "type": "string"
          }
        }
      },
      "ParsedCollateralCaps": {
        "type": "object",
        "required": [
          "maxAllocationPct",
          "currentAllocationAmount"
        ],
        "properties": {
          "currentAllocationAmount": {
            "type": "string"
          },
          "maxAllocationPct": {
            "type": "string"
          }
        }
      },
      "ParsedLendingVault": {
        "type": "object",
        "required": [
          "address",
          "nonce",
          "manager",
          "principalMint",
          "lpMint",
          "lpSupply",
          "cumulativePrincipalDeposited",
          "maxEarlyUnstakeFee",
          "depositsEnabled",
          "featured",
          "mintEnabled"
        ],
        "properties": {
          "address": {
            "type": "string"
          },
          "cumulativePrincipalDeposited": {
            "type": "string"
          },
          "depositsEnabled": {
            "type": "boolean"
          },
          "featured": {
            "type": "boolean"
          },
          "lpMint": {
            "type": "string"
          },
          "lpSupply": {
            "type": "string"
          },
          "manager": {
            "type": "string"
          },
          "maxEarlyUnstakeFee": {
            "type": "string"
          },
          "mintEnabled": {
            "type": "boolean"
          },
          "nonce": {
            "type": "string"
          },
          "principalMint": {
            "type": "string"
          },
          "tags": {
            "type": [
              "string",
              "null"
            ]
          },
          "vaultIdentifier": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "ParsedPrincipalCaps": {
        "type": "object",
        "description": "Parsed principal supply/borrow/withdraw caps: rolling 1h and 24h ceilings plus\nthe max concurrent outstanding, all in the principal mint's native units.",
        "required": [
          "max1hr",
          "max24hr",
          "maxOutstanding"
        ],
        "properties": {
          "max1hr": {
            "type": "string"
          },
          "max24hr": {
            "type": "string"
          },
          "maxOutstanding": {
            "type": "string"
          }
        }
      },
      "ParsedVaultRewardsSchedule": {
        "type": "object",
        "description": "A vault rewards emission schedule (per reward mint): emission rate, window,\ncumulative totals, and per-duration stake weights.",
        "required": [
          "id",
          "vaultAddress",
          "rewardMint",
          "totalWeightedStakeSupply",
          "rewardStartTime",
          "rewardEndTime",
          "emissionsPerSecond",
          "totalEmissionsAmount",
          "rewardIndex",
          "scheduleIndex",
          "emissionsClaimed",
          "createdAt",
          "lastRewardIndexUpdateTime",
          "durationStakeWeights"
        ],
        "properties": {
          "createdAt": {
            "type": "string"
          },
          "durationStakeWeights": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          },
          "emissionsClaimed": {
            "type": "string"
          },
          "emissionsPerSecond": {
            "type": "string"
          },
          "id": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "lastRewardIndexUpdateTime": {
            "type": "string"
          },
          "rewardEndTime": {
            "type": "string"
          },
          "rewardIndex": {
            "type": "string"
          },
          "rewardMint": {
            "type": "string"
          },
          "rewardStartTime": {
            "type": "string"
          },
          "scheduleIndex": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "totalEmissionsAmount": {
            "type": "string"
          },
          "totalWeightedStakeSupply": {
            "type": "string"
          },
          "vaultAddress": {
            "type": "string"
          }
        }
      },
      "Strategy": {
        "type": "object",
        "required": [
          "address",
          "version",
          "nonce",
          "bump",
          "principalMint",
          "tokenBalance",
          "lender",
          "originationsEnabled",
          "externalYieldSource",
          "interestPerSecond",
          "lastAccruedTimestamp",
          "liquidityBuffer",
          "interestFee",
          "principalFee",
          "originationFee",
          "originationCap",
          "externalYieldAmount",
          "currentDeployedAmount",
          "outstandingInterestAmount",
          "feeClaimable",
          "cumulativePrincipalOriginated",
          "cumulativeInterestAccrued",
          "cumulativeLoanCount",
          "activeLoanCount",
          "marketInformation",
          "closed",
          "lastInteractedTime",
          "lastInteractedTxn",
          "createdAt",
          "writeVersion",
          "supplyCap1hrPeriodStart",
          "supplyCap24hrPeriodStart",
          "supplyCap1hrAmount",
          "supplyCap24hrAmount",
          "borrowCap1hrPeriodStart",
          "borrowCap24hrPeriodStart",
          "borrowCap1hrAmount",
          "borrowCap24hrAmount",
          "withdrawCap1hrPeriodStart",
          "withdrawCap24hrPeriodStart",
          "withdrawCap1hrAmount",
          "withdrawCap24hrAmount"
        ],
        "properties": {
          "activeLoanCount": {
            "type": "string"
          },
          "address": {
            "type": "string"
          },
          "borrowCap1hrAmount": {
            "type": "string"
          },
          "borrowCap1hrPeriodStart": {
            "type": "string"
          },
          "borrowCap24hrAmount": {
            "type": "string"
          },
          "borrowCap24hrPeriodStart": {
            "type": "string"
          },
          "bump": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "closed": {
            "type": "boolean"
          },
          "createdAt": {
            "type": "string"
          },
          "cumulativeInterestAccrued": {
            "type": "string"
          },
          "cumulativeLoanCount": {
            "type": "string"
          },
          "cumulativePrincipalOriginated": {
            "type": "string"
          },
          "currentDeployedAmount": {
            "type": "string"
          },
          "externalYieldAmount": {
            "type": "string"
          },
          "externalYieldSource": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "feeClaimable": {
            "type": "string"
          },
          "id": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "interestFee": {
            "type": "string"
          },
          "interestPerSecond": {
            "type": "number",
            "format": "double"
          },
          "lastAccruedTimestamp": {
            "type": "string"
          },
          "lastInteractedTime": {
            "type": "string"
          },
          "lastInteractedTxn": {
            "type": "string"
          },
          "lender": {
            "type": "string"
          },
          "liquidityBuffer": {
            "type": "string"
          },
          "marketInformation": {
            "type": "string"
          },
          "nonce": {
            "type": "string"
          },
          "originationCap": {
            "type": "string"
          },
          "originationFee": {
            "type": "string"
          },
          "originationsEnabled": {
            "type": "boolean"
          },
          "outstandingInterestAmount": {
            "type": "string"
          },
          "principalFee": {
            "type": "string"
          },
          "principalMint": {
            "type": "string"
          },
          "supplyCap1hrAmount": {
            "type": "string"
          },
          "supplyCap1hrPeriodStart": {
            "type": "string"
          },
          "supplyCap24hrAmount": {
            "type": "string"
          },
          "supplyCap24hrPeriodStart": {
            "type": "string"
          },
          "tokenBalance": {
            "type": "string"
          },
          "version": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "withdrawCap1hrAmount": {
            "type": "string"
          },
          "withdrawCap1hrPeriodStart": {
            "type": "string"
          },
          "withdrawCap24hrAmount": {
            "type": "string"
          },
          "withdrawCap24hrPeriodStart": {
            "type": "string"
          },
          "writeVersion": {
            "type": "string"
          }
        }
      },
      "StrategyInfo": {
        "type": "object",
        "required": [
          "strategy",
          "terms",
          "borrowCapMonitor",
          "supplyCapMonitor",
          "withdrawCapMonitor"
        ],
        "properties": {
          "borrowCapMonitor": {
            "$ref": "#/components/schemas/ParsedCapMonitor"
          },
          "externalYieldInfo": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/ExternalYieldInfo"
              }
            ]
          },
          "strategy": {
            "$ref": "#/components/schemas/Strategy",
            "description": "Strategy account state (DB projection of the on-chain strategy)."
          },
          "supplyCapMonitor": {
            "$ref": "#/components/schemas/ParsedCapMonitor"
          },
          "terms": {
            "$ref": "#/components/schemas/StrategyTerms"
          },
          "withdrawCapMonitor": {
            "$ref": "#/components/schemas/ParsedCapMonitor"
          }
        }
      },
      "StrategyInfoUsdFields": {
        "type": "object",
        "description": "Per-strategy USD/APY summary (TVL, deployed, blended APY, …). Serialized as\nthe `strategySummary` on each vault when `/lending_vaults/info` is called\nwith `includeStrategySummaries`, mirroring the per-item fields of\n`StrategyDetail` from `POST /strategy/summaries`.",
        "required": [
          "principalDeployedUsd",
          "strategyBalanceUsd",
          "totalSupplyUsd",
          "interestAccruedUsd",
          "interestEarnedAllTimeUsd",
          "wAvgApy",
          "expected24hInterestUsd"
        ],
        "properties": {
          "expected24hInterestUsd": {
            "type": "number",
            "format": "double"
          },
          "interestAccruedUsd": {
            "type": "number",
            "format": "double"
          },
          "interestEarnedAllTimeUsd": {
            "type": "number",
            "format": "double"
          },
          "principalDeployedUsd": {
            "type": "number",
            "format": "double"
          },
          "strategyBalanceUsd": {
            "type": "number",
            "format": "double"
          },
          "totalSupplyUsd": {
            "type": "number",
            "format": "double"
          },
          "wAvgApy": {
            "type": "number",
            "format": "double"
          }
        }
      },
      "StrategyTerms": {
        "type": "object",
        "required": [
          "assetTerms",
          "supplyCaps",
          "borrowCaps",
          "withdrawCaps"
        ],
        "properties": {
          "assetTerms": {
            "type": "object",
            "additionalProperties": {
              "$ref": "#/components/schemas/AssetTerms"
            },
            "propertyNames": {
              "type": "string"
            }
          },
          "borrowCaps": {
            "$ref": "#/components/schemas/ParsedPrincipalCaps",
            "description": "Principal borrow caps (rolling 1h/24h + max outstanding)."
          },
          "supplyCaps": {
            "$ref": "#/components/schemas/ParsedPrincipalCaps",
            "description": "Principal supply caps (rolling 1h/24h + max outstanding)."
          },
          "withdrawCaps": {
            "$ref": "#/components/schemas/ParsedPrincipalCaps",
            "description": "Principal withdraw caps (rolling 1h/24h + max outstanding)."
          }
        }
      }
    }
  }
}
