> ## Documentation Index
> Fetch the complete documentation index at: https://docs.loopscale.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Deposit to Vault

> Deposit funds into a target lending Vault. On an additional deposit, the previous stake account and reward schedule is deleted and a new one is created.



## OpenAPI

````yaml post /markets/lending_vaults/deposit
openapi: 3.1.0
info:
  title: Loopscale API
  version: 0.1.0
servers:
  - url: https://tars.loopscale.com/v1
    description: Loopscale Production Server
security: []
paths:
  /markets/lending_vaults/deposit:
    post:
      tags:
        - lending_vaults
      summary: Vault deposit
      description: >-
        Deposit funds into a target lending Vault. On an additional deposit, the
        previous stake account and reward schedule is deleted and a new one is
        created.
      operationId: query_lend_vault_deposit
      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/LendVaultDepositQueryParams'
        required: true
      responses:
        '200':
          description: Serialized transaction and update stake account
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LendVaultDepositResponse'
        '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'
components:
  schemas:
    LendVaultDepositQueryParams:
      type: object
      required:
        - vault
        - principalAmount
        - minLpAmount
      properties:
        depositOnly:
          type: boolean
        minLpAmount:
          type: integer
          format: int64
          minimum: 0
        principalAmount:
          type: integer
          format: int64
          minimum: 0
        vault:
          type: string
    LendVaultDepositResponse:
      type: object
      required:
        - transaction
        - stakeAccount
      properties:
        preTransactions:
          type: array
          items:
            $ref: '#/components/schemas/VersionedTransactionReturn'
          description: >-
            Unstake-only transactions that must be executed before the main
            transaction

            when consolidating more positions than fit in a single transaction.
        stakeAccount:
          type: string
        transaction:
          $ref: '#/components/schemas/VersionedTransactionReturn'
    ErrorResponse:
      type: object
      description: |-
        Canonical error envelope for every endpoint. The `x-request-id` response
        header carries the correlation id for the failing request.
      required:
        - error
      properties:
        error:
          $ref: '#/components/schemas/ErrorDetails'
          description: error detail
    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
    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.
    VersionedTransactionSignature:
      type: object
      description: versioned txn return
      required:
        - publicKey
        - signature
      properties:
        publicKey:
          type: string
          description: serialized message
        signature:
          type: string
          description: serialized signatures

````