{
  "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/creditbook/create": {
      "post": {
        "tags": [
          "creditbook"
        ],
        "operationId": "query_create_loan",
        "parameters": [
          {
            "name": "Idempotent-Key",
            "in": "header",
            "description": "Optional idempotency key; a retried write with the same key replays the original response",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TxnCreateLoanParams"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Serialized transaction and derived loan address.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateLoanReturn"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Idempotency-Key reused with a different request body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "summary": "Create loan",
        "description": "Creates a new loan with initial collateral and requested principal borrows, returning both the loan address and the serialized transaction needed to initialize it."
      }
    },
    "/markets/creditbook/borrow": {
      "post": {
        "tags": [
          "creditbook"
        ],
        "operationId": "query_borrow_principal",
        "parameters": [
          {
            "name": "Idempotent-Key",
            "in": "header",
            "description": "Optional idempotency key; a retried write with the same key replays the original response",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TxnBorrowPrincipalParams"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Serialized transaction for borrowing additional principal.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LoanTxnResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Idempotency-Key reused with a different request body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "summary": "Borrow principal",
        "description": "Borrows additional principal against an existing loan and can optionally refinance the targeted ledger in the same transaction."
      }
    },
    "/markets/creditbook/collateral/deposit": {
      "post": {
        "tags": [
          "creditbook"
        ],
        "operationId": "query_deposit_collateral",
        "parameters": [
          {
            "name": "Idempotent-Key",
            "in": "header",
            "description": "Optional idempotency key; a retried write with the same key replays the original response",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TxnDepositCollateralParams"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Serialized transaction for depositing collateral.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VersionedTransactionReturn"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Idempotency-Key reused with a different request body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "summary": "Deposit collateral",
        "description": "Adds more collateral to an existing loan position."
      }
    },
    "/markets/creditbook/collateral/withdraw": {
      "post": {
        "tags": [
          "creditbook"
        ],
        "operationId": "query_withdraw_collateral",
        "parameters": [
          {
            "name": "Idempotent-Key",
            "in": "header",
            "description": "Optional idempotency key; a retried write with the same key replays the original response",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TxnWithdrawCollateralParams"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Serialized transaction for withdrawing collateral.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VersionedTransactionReturn"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Idempotency-Key reused with a different request body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "summary": "Withdraw collateral",
        "description": "Withdraws collateral from an existing loan. Full collateral removal may include internal weight-matrix and loan-lock handling before the transaction is returned."
      }
    },
    "/markets/creditbook/sell": {
      "post": {
        "tags": [
          "creditbook"
        ],
        "operationId": "query_sell_ledger",
        "parameters": [
          {
            "name": "Idempotent-Key",
            "in": "header",
            "description": "Optional idempotency key; a retried write with the same key replays the original response",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TxnSellLedgerParams"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Serialized transaction for selling the targeted ledger.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VersionedTransactionReturn"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Idempotency-Key reused with a different request body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "summary": "Sell ledger",
        "description": "Sells a loan ledger from one strategy into another strategy, using the expected sale price guard provided in the request."
      }
    },
    "/markets/creditbook/build": {
      "post": {
        "tags": [
          "creditbook"
        ],
        "operationId": "query_build_loan",
        "parameters": [
          {
            "name": "Idempotent-Key",
            "in": "header",
            "description": "Optional idempotency key; a retried write with the same key replays the original response",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LoanBuildParams"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Derived loan address and the transaction sequence produced by the requested build steps.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LoanBuildResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Idempotency-Key reused with a different request body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "summary": "Build loan",
        "description": "Builds or mutates a loan through a sequence of high-level actions. Supported step types currently include `repay`, `flashBorrow`, and `swapCollateral`."
      }
    },
    "/markets/creditbook/flash_borrow": {
      "post": {
        "tags": [
          "creditbook"
        ],
        "operationId": "query_flash_borrow",
        "parameters": [
          {
            "name": "Idempotent-Key",
            "in": "header",
            "description": "Optional idempotency key; a retried write with the same key replays the original response",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IncreaseLeverageTransactionInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Serialized transaction and resulting loan address",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LoanTxnResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Idempotency-Key reused with a different request body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "summary": "Flash borrow",
        "description": "Atomically creates a new loan and executes optional CPIs before depositing collateral. Supports deferred collateralization. Returns a transaction message and resulting loan address."
      }
    },
    "/markets/creditbook/swap_collateral": {
      "post": {
        "tags": [
          "creditbook"
        ],
        "operationId": "query_swap_collateral",
        "parameters": [
          {
            "name": "Idempotent-Key",
            "in": "header",
            "description": "Optional idempotency key; a retried write with the same key replays the original response",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TxnSwapCollateralParams"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Single versioned transaction message and signatures",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LoanTxnResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Idempotency-Key reused with a different request body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "summary": "Swap collateral",
        "description": "Enables safe rebalancing of collateral by withdrawing a selected asset, executing CPIs (e.g. swaps or liquidity provision), and depositing a new asset in its place."
      }
    },
    "/markets/creditbook/repay": {
      "post": {
        "tags": [
          "creditbook"
        ],
        "operationId": "query_repay_principal",
        "parameters": [
          {
            "name": "Idempotent-Key",
            "in": "header",
            "description": "Optional idempotency key; a retried write with the same key replays the original response",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TxnRepayPrincipalParams"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Serialized transaction message and signatures",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LoanTxnResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Idempotency-Key reused with a different request body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "summary": "Repay loan",
        "description": "Partially or fully repay an active loan. Allows for the withdrawal of collateral for optional use in CPIs before repayment."
      }
    },
    "/markets/creditbook/repay_simple": {
      "post": {
        "tags": [
          "creditbook"
        ],
        "operationId": "query_simple_repay_principal",
        "parameters": [
          {
            "name": "Idempotent-Key",
            "in": "header",
            "description": "Optional idempotency key; a retried write with the same key replays the original response",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TxnSimpleRepayPrincipalParams"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Serialized transactions and expected post-repayment loan state.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LoanTxnResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Idempotency-Key reused with a different request body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "summary": "Simple repay loan",
        "description": "A simplified repay endpoint that handles a single strategy at a time. Unlike the full repay endpoint, it does not support CPI instructions, collateral withdrawals, or setup instructions. If a ledger is fully repaid on a multi-ledger loan, weight matrix updates are automatically generated to redistribute collateral away from the emptied ledger."
      }
    },
    "/markets/creditbook/refinance": {
      "post": {
        "tags": [
          "creditbook"
        ],
        "operationId": "query_refinance_ledger",
        "parameters": [
          {
            "name": "Idempotent-Key",
            "in": "header",
            "description": "Optional idempotency key; a retried write with the same key replays the original response",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TxnRefinanceLedgerParams"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Serialized transaction",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LoanTxnResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Idempotency-Key reused with a different request body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "summary": "Refinance loan",
        "description": "Update the duration of the loan."
      }
    },
    "/markets/creditbook/close_loan": {
      "post": {
        "tags": [
          "creditbook"
        ],
        "operationId": "query_close_loan",
        "parameters": [
          {
            "name": "Idempotent-Key",
            "in": "header",
            "description": "Optional idempotency key; a retried write with the same key replays the original response",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TxnCloseLoanParams"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Serialized transaction",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LoanTxnResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Idempotency-Key reused with a different request body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "summary": "Close loan",
        "description": "In the event a loan is fully repaid and all collateral is withdrawn, but wasn't closed, this directly closes the loan account and refunds the user."
      }
    }
  },
  "components": {
    "schemas": {
      "ApiLoanEventActionMetadata": {
        "oneOf": [
          {
            "type": "object",
            "required": [
              "type"
            ],
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "addCollateral"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "type"
            ],
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "removeCollateral"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "params",
              "type"
            ],
            "properties": {
              "params": {
                "$ref": "#/components/schemas/ParsedBorrowPrincipalMetadata"
              },
              "type": {
                "type": "string",
                "enum": [
                  "borrowPrincipal"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "params",
              "type"
            ],
            "properties": {
              "params": {
                "$ref": "#/components/schemas/ParsedRepayPrincipalMetadata"
              },
              "type": {
                "type": "string",
                "enum": [
                  "repayPrincipal"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "params",
              "type"
            ],
            "properties": {
              "params": {
                "$ref": "#/components/schemas/ParsedRefinanceLedgerMetadata"
              },
              "type": {
                "type": "string",
                "enum": [
                  "refinanceLedger"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "params",
              "type"
            ],
            "properties": {
              "params": {
                "$ref": "#/components/schemas/ParsedSellLedgerMetadata"
              },
              "type": {
                "type": "string",
                "enum": [
                  "sellLedger"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "params",
              "type"
            ],
            "properties": {
              "params": {
                "$ref": "#/components/schemas/ParsedLiquidateLedgerMetadata"
              },
              "type": {
                "type": "string",
                "enum": [
                  "liquidate"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "params",
              "type"
            ],
            "properties": {
              "params": {
                "$ref": "#/components/schemas/ParsedMigrateLedgerMetadata"
              },
              "type": {
                "type": "string",
                "enum": [
                  "migrate"
                ]
              }
            }
          }
        ],
        "description": "API-specific representation of loan event metadata (adjacently-tagged:\n`{ \"type\": <action>, \"params\": <metadata> }`)."
      },
      "AssetDataInfo": {
        "oneOf": [
          {
            "type": "object",
            "required": [
              "Spl"
            ],
            "properties": {
              "Spl": {
                "$ref": "#/components/schemas/SplData"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "StakedSol"
            ],
            "properties": {
              "StakedSol": {
                "$ref": "#/components/schemas/StakedSolData"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "Orca"
            ],
            "properties": {
              "Orca": {
                "$ref": "#/components/schemas/OrcaPositionData"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "Meteora"
            ],
            "properties": {
              "Meteora": {
                "$ref": "#/components/schemas/MeteoraDlmmPositionData"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "Raydium"
            ],
            "properties": {
              "Raydium": {
                "$ref": "#/components/schemas/RaydiumPositionData"
              }
            }
          }
        ],
        "description": "Collateral asset identification, tagged by collateral kind (SPL token,\nstaked SOL, or a CLMM LP position on Orca / Meteora / Raydium)."
      },
      "BorrowPrincipalParamsSchema": {
        "type": "object",
        "description": "Params for borrowing principal against an existing loan (`borrow_principal`).",
        "required": [
          "amount",
          "assetIndexGuidance",
          "duration",
          "expectedLoanValues",
          "skipSolUnwrap"
        ],
        "properties": {
          "amount": {
            "type": "integer",
            "format": "int64",
            "description": "Principal amount to borrow, in the principal mint's native units.",
            "minimum": 0
          },
          "assetIndexGuidance": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            },
            "description": "Per-collateral oracle asset-index guidance."
          },
          "duration": {
            "type": "integer",
            "format": "int32",
            "description": "Index into the strategy's offered durations for this ledger.",
            "minimum": 0
          },
          "expectedLoanValues": {
            "$ref": "#/components/schemas/ExpectedLoanValuesSchema"
          },
          "skipSolUnwrap": {
            "type": "boolean",
            "description": "When true, keep borrowed SOL wrapped instead of unwrapping to native SOL."
          }
        }
      },
      "BorrowPrincipalRequested": {
        "type": "object",
        "required": [
          "ledgerIndex",
          "principalAmount",
          "principalMint",
          "strategy",
          "durationIndex",
          "expectedLoanValues"
        ],
        "properties": {
          "durationIndex": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "expectedLoanValues": {
            "$ref": "#/components/schemas/ExpectedLoanValuesSchema"
          },
          "ledgerIndex": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "principalAmount": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "principalMint": {
            "type": "string"
          },
          "strategy": {
            "type": "string"
          }
        }
      },
      "CreateLoanReturn": {
        "type": "object",
        "required": [
          "transaction",
          "loanAddress"
        ],
        "properties": {
          "loanAddress": {
            "type": "string"
          },
          "transaction": {
            "$ref": "#/components/schemas/VersionedTransactionReturn"
          }
        }
      },
      "DepositCollateralInput": {
        "type": "object",
        "required": [
          "collateralAmount",
          "collateralAssetData"
        ],
        "properties": {
          "collateralAmount": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "collateralAssetData": {
            "$ref": "#/components/schemas/AssetDataInfo"
          },
          "loanCreationParams": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/LoanCreationParams"
              }
            ]
          },
          "weightMatrixUpdate": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          }
        }
      },
      "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"
          }
        }
      },
      "ExpectedLoanValuesSchema": {
        "type": "object",
        "description": "Expected loan economics the borrower signs off on, checked on-chain against the\nfreshly-priced values to bound slippage.",
        "required": [
          "expectedApy",
          "expectedLqt"
        ],
        "properties": {
          "expectedApy": {
            "type": "integer",
            "format": "int64",
            "description": "Expected loan APY, in basis points of a hundredth (cbps).",
            "minimum": 0
          },
          "expectedLqt": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            },
            "description": "Expected per-ledger liquidation threshold, one entry per ledger slot."
          }
        }
      },
      "GenericParsedLoanEvent": {
        "type": "object",
        "description": "A parsed loan lifecycle event with action-specific metadata in `actionMetadata`.",
        "required": [
          "id",
          "loan",
          "assetIdentifier",
          "amount",
          "action",
          "actionMetadata",
          "eventTime",
          "eventTxn"
        ],
        "properties": {
          "action": {
            "$ref": "#/components/schemas/LoanEventType"
          },
          "actionMetadata": {
            "$ref": "#/components/schemas/ApiLoanEventActionMetadata"
          },
          "amount": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "assetIdentifier": {
            "type": "string"
          },
          "assetMint": {
            "type": [
              "string",
              "null"
            ]
          },
          "eventTime": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "eventTxn": {
            "type": "string"
          },
          "id": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "loan": {
            "type": "string"
          },
          "newLender": {
            "type": [
              "string",
              "null"
            ]
          },
          "originalLender": {
            "type": [
              "string",
              "null"
            ]
          },
          "usdPrice": {
            "type": [
              "number",
              "null"
            ],
            "format": "double"
          }
        }
      },
      "IncreaseLeverageTransactionInput": {
        "type": "object",
        "required": [
          "principalRequested",
          "depositCollateral"
        ],
        "properties": {
          "cpiIxs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ParsedInstruction"
            },
            "description": "Caller-supplied CPI instructions spliced into the built transaction."
          },
          "cpiLuts": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "cpiSigners": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "depositCollateral": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DepositCollateralInput"
            },
            "description": "Collateral to deposit alongside the borrow."
          },
          "isLoop": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "loanAddress": {
            "type": [
              "string",
              "null"
            ]
          },
          "nonce": {
            "type": [
              "string",
              "null"
            ]
          },
          "principalRequested": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BorrowPrincipalRequested"
            },
            "description": "Per-ledger principal borrow requests."
          },
          "refinanceParams": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/RefinanceLedgerParamsSchema",
                "description": "Optional on-chain refinance params."
              }
            ]
          },
          "setupIxs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ParsedInstruction"
            },
            "description": "Setup instructions run before the main instructions."
          },
          "setupLuts": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "setupSigners": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "unifySetup": {
            "type": "boolean"
          }
        }
      },
      "Ledger": {
        "type": "object",
        "required": [
          "ledgerIndex",
          "loan",
          "status",
          "strategy",
          "principalMint",
          "marketInformation",
          "principalDue",
          "principalRepaid",
          "interestOutstanding",
          "lastInterestUpdatedTime",
          "interestPerSecond",
          "duration",
          "durationType",
          "startTime",
          "endTime",
          "apy",
          "weights",
          "ltvRatios",
          "lqtRatios",
          "lastInteractedTime",
          "lastInteractedTxn"
        ],
        "properties": {
          "apy": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "duration": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "durationType": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "endTime": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "id": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "interestOutstanding": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "interestPerSecond": {
            "type": "number",
            "format": "double"
          },
          "isLoop": {
            "type": "integer",
            "format": "int32"
          },
          "lastInteractedTime": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "lastInteractedTxn": {
            "type": "string"
          },
          "lastInterestUpdatedTime": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "ledgerIndex": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "loan": {
            "type": "string"
          },
          "lqtRatios": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            },
            "description": "Per-collateral liquidation thresholds (cbps), same index order as `weights`."
          },
          "ltvRatios": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            },
            "description": "Per-collateral loan-to-value ratios (cbps), same index order as `weights`."
          },
          "marketInformation": {
            "type": "string"
          },
          "principalDue": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "principalMint": {
            "type": "string"
          },
          "principalRepaid": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "startTime": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "status": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "strategy": {
            "type": "string"
          },
          "weights": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            },
            "description": "Weight matrix: per-collateral weight (cbps), indexed by the market's\ncollateral map. Drives how each collateral backs this ledger's principal."
          },
          "writeVersion": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          }
        }
      },
      "Loan": {
        "type": "object",
        "required": [
          "address",
          "bump",
          "loanStatus",
          "nonce",
          "borrower",
          "startTime",
          "closed",
          "lastInteractedTime",
          "lastInteractedTxn",
          "writeVersion"
        ],
        "properties": {
          "address": {
            "type": "string"
          },
          "borrower": {
            "type": "string"
          },
          "bump": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "closed": {
            "type": "boolean"
          },
          "id": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "lastInteractedTime": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "lastInteractedTxn": {
            "type": "string"
          },
          "loanStatus": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "nonce": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "startTime": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "writeVersion": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          }
        }
      },
      "LoanBuildParams": {
        "type": "object",
        "required": [
          "steps"
        ],
        "properties": {
          "loan": {
            "type": [
              "string",
              "null"
            ]
          },
          "steps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LoanBuildStep"
            },
            "description": "Ordered build steps."
          }
        }
      },
      "LoanBuildResponse": {
        "type": "object",
        "required": [
          "loan",
          "transactions"
        ],
        "properties": {
          "loan": {
            "type": "string"
          },
          "transactions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/VersionedTransactionReturn"
            }
          }
        }
      },
      "LoanBuildStep": {
        "oneOf": [
          {
            "type": "object",
            "required": [
              "params",
              "type"
            ],
            "properties": {
              "params": {
                "$ref": "#/components/schemas/TxnRepayPrincipalParams"
              },
              "type": {
                "type": "string",
                "enum": [
                  "repay"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "params",
              "type"
            ],
            "properties": {
              "params": {
                "$ref": "#/components/schemas/IncreaseLeverageTransactionInput"
              },
              "type": {
                "type": "string",
                "enum": [
                  "flashBorrow"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "params",
              "type"
            ],
            "properties": {
              "params": {
                "$ref": "#/components/schemas/TxnSwapCollateralParams"
              },
              "type": {
                "type": "string",
                "enum": [
                  "swapCollateral"
                ]
              }
            }
          }
        ],
        "description": "One step of a composed loan build, adjacently-tagged by `type` with the\nstep's own transaction params under `params`."
      },
      "LoanCollateral": {
        "type": "object",
        "required": [
          "loan",
          "index",
          "assetType",
          "assetIdentifier",
          "assetMint",
          "amount"
        ],
        "properties": {
          "amount": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "assetIdentifier": {
            "type": "string"
          },
          "assetMint": {
            "type": "string"
          },
          "assetType": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "id": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "index": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "lastInteractedTime": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "lastInteractedTxn": {
            "type": "string"
          },
          "loan": {
            "type": "string"
          },
          "writeVersion": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          }
        }
      },
      "LoanCreationParams": {
        "oneOf": [
          {
            "type": "string",
            "enum": [
              "Default"
            ]
          },
          {
            "type": "object",
            "required": [
              "OrcaPositionCreate"
            ],
            "properties": {
              "OrcaPositionCreate": {
                "$ref": "#/components/schemas/OrcaPositionCreateParams"
              }
            }
          }
        ],
        "description": "Optional collateral-specific loan-creation params (e.g. opening an Orca CLMM\nposition as collateral); `Default` for a plain loan."
      },
      "LoanEventType": {
        "type": "string",
        "enum": [
          "addCollateral",
          "removeCollateral",
          "borrowPrincipal",
          "repayPrincipal",
          "refinanceLedger",
          "sellLedger",
          "liquidate"
        ]
      },
      "LoanInfo": {
        "type": "object",
        "required": [
          "loan",
          "loanType",
          "ledgers",
          "collateral",
          "collateralYieldPct",
          "principalYieldPct"
        ],
        "properties": {
          "collateral": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LoanCollateral"
            }
          },
          "collateralYieldPct": {
            "type": "number",
            "format": "double"
          },
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/GenericParsedLoanEvent"
            }
          },
          "ledgers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Ledger"
            }
          },
          "loan": {
            "$ref": "#/components/schemas/Loan"
          },
          "loanType": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "matrixUpdates": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LoanMatrixEvent"
            }
          },
          "pastLedgers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Ledger"
            }
          },
          "principalYieldPct": {
            "type": "number",
            "format": "double"
          }
        }
      },
      "LoanMatrixEvent": {
        "type": "object",
        "description": "A recorded weight-matrix update on a loan: the new per-collateral weight / LTV\n/ LQT matrices at a point in time (one row per `update_weight_matrix`).",
        "required": [
          "loan",
          "weights",
          "lqtRatios",
          "ltvRatios",
          "timestamp",
          "txnSignature",
          "ledgerIndex",
          "writeVersion"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "ledgerIndex": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "loan": {
            "type": "string"
          },
          "lqtRatios": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            },
            "description": "Per-collateral liquidation thresholds (cbps) after this update."
          },
          "ltvRatios": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            },
            "description": "Per-collateral loan-to-value ratios (cbps) after this update."
          },
          "timestamp": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "txnSignature": {
            "type": "string"
          },
          "weights": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            },
            "description": "Weight matrix (per-collateral weight, cbps) after this update."
          },
          "writeVersion": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          }
        }
      },
      "LoanTxnResponse": {
        "type": "object",
        "required": [
          "transactions",
          "expectedLoanInfo"
        ],
        "properties": {
          "expectedLoanInfo": {
            "$ref": "#/components/schemas/LoanInfo",
            "description": "Projected loan state after the transactions land."
          },
          "transactions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/VersionedTransactionReturn"
            },
            "description": "Built, ready-to-sign versioned transactions."
          }
        }
      },
      "MeteoraDlmmPositionData": {
        "type": "object",
        "required": [
          "positionAddress",
          "lbPair"
        ],
        "properties": {
          "lbPair": {
            "type": "string"
          },
          "positionAddress": {
            "type": "string"
          },
          "tokenProgram": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "OrcaPositionCreateParams": {
        "type": "object",
        "required": [
          "upperTick",
          "lowerTick",
          "tickSpacing",
          "whirlpool",
          "tokenMintA",
          "tokenMintB"
        ],
        "properties": {
          "lowerTick": {
            "type": "integer",
            "format": "int32"
          },
          "tickSpacing": {
            "type": "integer",
            "format": "int32"
          },
          "tokenMintA": {
            "type": "string"
          },
          "tokenMintB": {
            "type": "string"
          },
          "upperTick": {
            "type": "integer",
            "format": "int32"
          },
          "whirlpool": {
            "type": "string"
          }
        }
      },
      "OrcaPositionData": {
        "type": "object",
        "required": [
          "positionMint",
          "whirlpool"
        ],
        "properties": {
          "positionMint": {
            "type": "string"
          },
          "tokenProgram": {
            "type": [
              "string",
              "null"
            ]
          },
          "whirlpool": {
            "type": "string"
          }
        }
      },
      "ParsedAccountMeta": {
        "type": "object",
        "description": "One account reference of a parsed Solana instruction.",
        "required": [
          "pubkey",
          "isSigner",
          "isWritable"
        ],
        "properties": {
          "isSigner": {
            "type": "boolean",
            "description": "whether the account must sign"
          },
          "isWritable": {
            "type": "boolean",
            "description": "whether the account is written"
          },
          "pubkey": {
            "type": "string",
            "description": "account pubkey (base58)"
          }
        }
      },
      "ParsedBorrowPrincipalMetadata": {
        "type": "object",
        "required": [
          "preBorrowPrincipalLedgerState",
          "postBorrowPrincipalLedgerState"
        ],
        "properties": {
          "postBorrowPrincipalLedgerState": {
            "$ref": "#/components/schemas/ParsedEventLedger"
          },
          "preBorrowPrincipalLedgerState": {
            "$ref": "#/components/schemas/ParsedEventLedger"
          }
        }
      },
      "ParsedEventLedger": {
        "type": "object",
        "description": "Snapshot of a ledger's state captured in an event's before/after metadata.",
        "required": [
          "status",
          "strategy",
          "principalMint",
          "marketInformation",
          "principalDue",
          "principalRepaid",
          "duration",
          "interestPerSecond",
          "apy",
          "endTime",
          "startTime"
        ],
        "properties": {
          "apy": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "duration": {
            "$ref": "#/components/schemas/StrategyDuration"
          },
          "endTime": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "interestOutstanding": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "interestPerSecond": {
            "type": "number",
            "format": "double"
          },
          "lastInterestUpdatedTime": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "ledgerIndex": {
            "type": "integer",
            "minimum": 0
          },
          "marketInformation": {
            "type": "string"
          },
          "principalDue": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "principalMint": {
            "type": "string"
          },
          "principalRepaid": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "startTime": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "status": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "strategy": {
            "type": "string"
          }
        }
      },
      "ParsedInstruction": {
        "type": "object",
        "description": "A parsed Solana instruction (program id, ordered account metas, and base58\ninstruction data) spliced verbatim into a built transaction as a CPI.",
        "required": [
          "programId",
          "accounts",
          "data"
        ],
        "properties": {
          "accounts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ParsedAccountMeta"
            },
            "description": "ordered account metas"
          },
          "data": {
            "type": "string",
            "description": "base58-encoded instruction data"
          },
          "programId": {
            "type": "string",
            "description": "program id (base58)"
          }
        }
      },
      "ParsedLiquidatedCollateralMetadata": {
        "type": "object",
        "required": [
          "assetMint",
          "amount",
          "toLiquidator",
          "price"
        ],
        "properties": {
          "amount": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "assetMint": {
            "type": "string"
          },
          "price": {
            "type": "number",
            "format": "double"
          },
          "toLiquidator": {
            "type": "boolean"
          }
        }
      },
      "ParsedLiquidateLedgerMetadata": {
        "type": "object",
        "required": [
          "ledgerIndex",
          "isTimeBasedLiquidation",
          "collateralTransfers",
          "liquidationFee"
        ],
        "properties": {
          "collateralTransfers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ParsedLiquidatedCollateralMetadata"
            }
          },
          "isTimeBasedLiquidation": {
            "type": "boolean"
          },
          "ledgerIndex": {
            "type": "integer",
            "minimum": 0
          },
          "liquidationFee": {
            "type": "number",
            "format": "double"
          }
        }
      },
      "ParsedMigrateLedgerMetadata": {
        "type": "object",
        "required": [
          "lockboxAddr"
        ],
        "properties": {
          "lockboxAddr": {
            "type": "string"
          }
        }
      },
      "ParsedRefinanceLedgerMetadata": {
        "type": "object",
        "required": [
          "preRefinanceLedgerState",
          "postRefinanceLedgerState"
        ],
        "properties": {
          "postRefinanceLedgerState": {
            "$ref": "#/components/schemas/ParsedEventLedger"
          },
          "preRefinanceLedgerState": {
            "$ref": "#/components/schemas/ParsedEventLedger"
          }
        }
      },
      "ParsedRepayPrincipalMetadata": {
        "type": "object",
        "required": [
          "preRepaymentPrincipalLedgerState",
          "postRepaymentPrincipalLedgerState"
        ],
        "properties": {
          "postRepaymentPrincipalLedgerState": {
            "$ref": "#/components/schemas/ParsedEventLedger"
          },
          "preRepaymentPrincipalLedgerState": {
            "$ref": "#/components/schemas/ParsedEventLedger"
          }
        }
      },
      "ParsedSellLedgerMetadata": {
        "type": "object",
        "required": [
          "buyer",
          "seller"
        ],
        "properties": {
          "buyer": {
            "type": "string"
          },
          "seller": {
            "type": "string"
          }
        }
      },
      "RaydiumPositionData": {
        "type": "object",
        "required": [
          "mint",
          "pool"
        ],
        "properties": {
          "mint": {
            "type": "string"
          },
          "pool": {
            "type": "string"
          },
          "tokenProgram": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "RefinanceLedgerParamsSchema": {
        "type": "object",
        "description": "Params for refinancing a ledger to a new strategy/duration (`refinance_ledger`).",
        "required": [
          "ledgerIndex",
          "durationIndex",
          "assetIndexGuidance"
        ],
        "properties": {
          "assetIndexGuidance": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            },
            "description": "Per-collateral oracle asset-index guidance."
          },
          "durationIndex": {
            "type": "integer",
            "format": "int32",
            "description": "Index into the new strategy's offered durations.",
            "minimum": 0
          },
          "ledgerIndex": {
            "type": "integer",
            "format": "int32",
            "description": "Index of the ledger being refinanced.",
            "minimum": 0
          }
        }
      },
      "RepayPrincipalParamsSchema": {
        "type": "object",
        "description": "Params for repaying principal on a ledger (`repay_principal`).",
        "required": [
          "amount",
          "ledgerIndex",
          "repayAll"
        ],
        "properties": {
          "amount": {
            "type": "integer",
            "format": "int64",
            "description": "Amount to repay, in the principal mint's native units (ignored if `repay_all`).",
            "minimum": 0
          },
          "ledgerIndex": {
            "type": "integer",
            "format": "int32",
            "description": "Index of the ledger being repaid.",
            "minimum": 0
          },
          "repayAll": {
            "type": "boolean",
            "description": "Repay the ledger's full outstanding principal + interest."
          }
        }
      },
      "SellLedgerParamsSchema": {
        "type": "object",
        "description": "Params for selling a ledger to a new lender/strategy (`sell_ledger`).",
        "required": [
          "ledgerIndex",
          "expectedSalePrice",
          "assetIndexGuidance"
        ],
        "properties": {
          "assetIndexGuidance": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            },
            "description": "Per-collateral oracle asset-index guidance."
          },
          "expectedSalePrice": {
            "type": "integer",
            "format": "int64",
            "description": "Sale price the seller expects, in the principal mint's native units.",
            "minimum": 0
          },
          "ledgerIndex": {
            "type": "integer",
            "format": "int32",
            "description": "Index of the ledger being sold.",
            "minimum": 0
          }
        }
      },
      "SplData": {
        "type": "object",
        "required": [
          "mint"
        ],
        "properties": {
          "mint": {
            "type": "string"
          }
        }
      },
      "StakedSolData": {
        "type": "object",
        "required": [
          "stakeAccount",
          "stakePool"
        ],
        "properties": {
          "stakeAccount": {
            "type": "string"
          },
          "stakePool": {
            "type": "string"
          }
        }
      },
      "StakeLpQueryParams": {
        "type": "object",
        "required": [
          "vault",
          "amount"
        ],
        "properties": {
          "amount": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "stakeAccount": {
            "type": [
              "string",
              "null"
            ]
          },
          "vault": {
            "type": "string"
          }
        }
      },
      "StrategyDuration": {
        "type": "object",
        "required": [
          "duration",
          "durationType"
        ],
        "properties": {
          "duration": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "durationType": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          }
        }
      },
      "TxnBorrowPrincipalParams": {
        "type": "object",
        "required": [
          "loan",
          "borrowParams",
          "strategy"
        ],
        "properties": {
          "borrowParams": {
            "$ref": "#/components/schemas/BorrowPrincipalParamsSchema",
            "description": "On-chain borrow params."
          },
          "isLoop": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "loan": {
            "type": "string",
            "description": "Loan account address (base58)."
          },
          "refinanceParams": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/RefinanceLedgerParamsSchema",
                "description": "Optional on-chain refinance params."
              }
            ]
          },
          "strategy": {
            "type": "string",
            "description": "Strategy account address (base58)."
          },
          "weightMatrixUpdates": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WeightMatrixUpdateParams"
            }
          }
        }
      },
      "TxnCloseLoanParams": {
        "type": "object",
        "required": [
          "loan"
        ],
        "properties": {
          "loan": {
            "type": "string"
          }
        }
      },
      "TxnCreateLoanParams": {
        "type": "object",
        "required": [
          "depositCollateral",
          "borrower",
          "principalRequested"
        ],
        "properties": {
          "assetIndexGuidance": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            },
            "description": "Per-collateral oracle asset-index guidance (one byte per collateral slot)."
          },
          "borrower": {
            "type": "string"
          },
          "depositCollateral": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DepositCollateralInput"
            }
          },
          "isLoop": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "loanNonce": {
            "type": [
              "string",
              "null"
            ]
          },
          "principalRequested": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BorrowPrincipalRequested"
            }
          },
          "unstakeInstructions": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/UnstakeLpQueryParams",
                "description": "Optional vault LP unstake leg to compose with this txn as a prefix."
              }
            ]
          }
        }
      },
      "TxnDepositCollateralParams": {
        "type": "object",
        "required": [
          "loan",
          "depositMint",
          "amount",
          "assetType",
          "assetIdentifier"
        ],
        "properties": {
          "amount": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "assetIdentifier": {
            "type": "string"
          },
          "assetIndexGuidance": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            },
            "description": "Per-collateral oracle asset-index guidance (one byte per collateral slot)."
          },
          "assetType": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "depositMint": {
            "type": "string"
          },
          "expectedLoanValues": {
            "$ref": "#/components/schemas/ExpectedLoanValuesSchema"
          },
          "loan": {
            "type": "string"
          },
          "lockLoan": {
            "type": "boolean"
          },
          "unstakeInstructions": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/UnstakeLpQueryParams"
              }
            ]
          }
        }
      },
      "TxnRefinanceLedgerParams": {
        "type": "object",
        "required": [
          "loan",
          "oldStrategy",
          "newStrategy",
          "principalMint",
          "refinanceParams"
        ],
        "properties": {
          "loan": {
            "type": "string"
          },
          "newStrategy": {
            "type": "string"
          },
          "oldStrategy": {
            "type": "string"
          },
          "principalMint": {
            "type": "string"
          },
          "refinanceParams": {
            "$ref": "#/components/schemas/RefinanceLedgerParamsSchema"
          }
        }
      },
      "TxnRepayPrincipalParams": {
        "type": "object",
        "required": [
          "loan",
          "repayParams"
        ],
        "properties": {
          "closeIfPossible": {
            "type": "boolean"
          },
          "collateralWithdrawalParams": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WithdrawCollateralParams"
            }
          },
          "cpiIxs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ParsedInstruction"
            },
            "description": "Caller-supplied CPI instructions spliced into the built transaction."
          },
          "cpiLuts": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "cpiSigners": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "loan": {
            "type": "string"
          },
          "repayParams": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RepayPrincipalParamsSchema"
            }
          },
          "setupIxs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ParsedInstruction"
            },
            "description": "Setup instructions run before the main instructions."
          },
          "setupLuts": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "setupSigners": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "stakeInstructions": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/StakeLpQueryParams",
                "description": "Optional vault LP stake leg to compose with this txn as a suffix.\nUsed to stake collateral released by repayments."
              }
            ]
          },
          "unifySetup": {
            "type": "boolean"
          },
          "weightMatrixUpdates": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WeightMatrixUpdateParams"
            }
          }
        }
      },
      "TxnSellLedgerParams": {
        "type": "object",
        "required": [
          "loan",
          "oldStrategy",
          "newStrategy",
          "sellParams"
        ],
        "properties": {
          "loan": {
            "type": "string"
          },
          "newStrategy": {
            "type": "string"
          },
          "oldStrategy": {
            "type": "string"
          },
          "sellParams": {
            "$ref": "#/components/schemas/SellLedgerParamsSchema"
          }
        }
      },
      "TxnSimpleRepayPrincipalParams": {
        "type": "object",
        "required": [
          "loan",
          "repayParams",
          "strategy"
        ],
        "properties": {
          "isLoop": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "loan": {
            "type": "string",
            "description": "Loan account address (base58)."
          },
          "repayParams": {
            "$ref": "#/components/schemas/RepayPrincipalParamsSchema",
            "description": "On-chain repay params."
          },
          "strategy": {
            "type": "string",
            "description": "Strategy account address (base58)."
          },
          "weightMatrixUpdates": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WeightMatrixUpdateParams"
            }
          }
        }
      },
      "TxnSwapCollateralParams": {
        "type": "object",
        "required": [
          "loan",
          "withdrawCollateral",
          "depositCollateral"
        ],
        "properties": {
          "cpiIxs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ParsedInstruction"
            },
            "description": "Caller-supplied CPI instructions spliced into the built transaction."
          },
          "cpiLuts": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "cpiSigners": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "depositCollateral": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DepositCollateralInput"
            }
          },
          "loan": {
            "type": "string"
          },
          "withdrawCollateral": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WithdrawCollateralParams"
            }
          }
        }
      },
      "TxnWithdrawCollateralParams": {
        "type": "object",
        "required": [
          "loan",
          "collateralMint",
          "amount",
          "collateralIndex",
          "expectedLoanValues"
        ],
        "properties": {
          "amount": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "assetIndexGuidance": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            },
            "description": "Per-collateral oracle asset-index guidance (one byte per collateral slot)."
          },
          "collateralIndex": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "collateralMint": {
            "type": "string"
          },
          "expectedLoanValues": {
            "$ref": "#/components/schemas/ExpectedLoanValuesSchema"
          },
          "loan": {
            "type": "string"
          },
          "lockLoan": {
            "type": "boolean"
          },
          "skipClose": {
            "type": "boolean"
          },
          "stakeInstructions": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/StakeLpQueryParams"
              }
            ]
          }
        }
      },
      "UnstakeLpQueryParams": {
        "type": "object",
        "required": [
          "vault",
          "amount"
        ],
        "properties": {
          "amount": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "stakeAccount": {
            "type": [
              "string",
              "null"
            ]
          },
          "vault": {
            "type": "string"
          }
        }
      },
      "VersionedTransactionReturn": {
        "type": "object",
        "description": "versioned txn return",
        "required": [
          "message",
          "signatures"
        ],
        "properties": {
          "message": {
            "type": "string",
            "description": "serialized message"
          },
          "signatures": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/VersionedTransactionSignature"
            },
            "description": "serialized signatures"
          }
        }
      },
      "VersionedTransactionSignature": {
        "type": "object",
        "description": "versioned txn return",
        "required": [
          "publicKey",
          "signature"
        ],
        "properties": {
          "publicKey": {
            "type": "string",
            "description": "serialized message"
          },
          "signature": {
            "type": "string",
            "description": "serialized signatures"
          }
        }
      },
      "WeightMatrixUpdateParams": {
        "type": "object",
        "required": [
          "weightMatrixUpdate",
          "collateralIndex"
        ],
        "properties": {
          "collateralIndex": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          },
          "weightMatrixUpdate": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          }
        }
      },
      "WithdrawCollateralParams": {
        "type": "object",
        "required": [
          "collateralMint",
          "amount"
        ],
        "properties": {
          "amount": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "closeIfEligible": {
            "type": "boolean"
          },
          "collateralMint": {
            "type": "string"
          }
        }
      }
    }
  }
}
