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

# Open Position

> Opens a lending position by advancing funds into its one-time wallet and running the instructions supplied in `main_tx` in the same transaction.



## OpenAPI

````yaml POST /borrow/initiate
openapi: 3.0.1
info:
  title: Vanish Core API
  description: API endpoints for the Vanish Core service.
  license:
    name: MIT
  version: 2.0.0
servers:
  - url: https://core-api-dev.vanish.trade
security:
  - ApiKeyAuth: []
paths:
  /borrow/initiate:
    post:
      summary: Open Position
      description: >-
        Opens a lending position by advancing funds into its one-time wallet and
        running the instructions supplied in `main_tx` in the same transaction.
      requestBody:
        description: Details of the request to open a position.
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BorrowInitiateRequest'
        required: true
      responses:
        '200':
          description: Successful lending action response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BorrowActionResponse'
        '400':
          description: >-
            Bad request. The amount is not greater than 0, the one-time wallet
            was not found or does not belong to this user, the balance available
            for the token is insufficient, the transaction failed simulation, or
            an action was already initiated with this signature.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BorrowError'
        '401':
          description: >-
            Unauthorized. The request is missing a valid API key or the
            signature is invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BorrowError'
        '429':
          description: >-
            Rate limit exceeded. Contact the Vanish team to raise your team's
            requests-per-second cap.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BorrowError'
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BorrowError'
components:
  schemas:
    BorrowInitiateRequest:
      required:
        - smart_wallet_id
        - user_address
        - source_token_address
        - amount
        - loan_additional_sol
        - jito_tip_amount
        - main_tx
        - timestamp
        - user_signature
      type: object
      properties:
        smart_wallet_id:
          description: >-
            Identifier of the one-time wallet the funds are advanced into,
            returned by the /borrow/smart-wallet endpoint. Must belong to
            user_address.
          type: integer
          example: 4821
        user_address:
          description: The Solana wallet address of the user opening the position.
          type: string
        source_token_address:
          description: >-
            The address of the token being advanced into the one-time wallet.
            Wrapped SOL is normalised to native SOL after the signature check.
          type: string
        amount:
          description: >-
            The amount to advance into the one-time wallet, expressed in the
            smallest unit (e.g., lamports for SOL). Must be greater than 0. Can
            be provided as a string or a number
          oneOf:
            - type: string
              pattern: ^[0-9]+$
            - type: integer
              format: int64
        loan_additional_sol:
          description: >-
            Additional SOL (in lamports) advanced for ATA creation. Required the
            first time the position uses a token - one ATA costs about 2039280
            lamports - with any unused amount refunded. Pass 0 when the wallet
            already holds enough. Can be provided as a string or a number
          oneOf:
            - type: string
              pattern: ^[0-9]+$
            - type: integer
              format: int64
        jito_tip_amount:
          description: >-
            Jito tip in lamports. Only applied when the transaction overflows
            Solana's size limit and a two-transaction bundle is used, but always
            required - it is part of the signed message either way. Can be
            provided as a string or a number
          oneOf:
            - type: string
              pattern: ^[0-9]+$
            - type: integer
              format: int64
        main_tx:
          description: >-
            Serialized or encoded transaction data carrying your own deposit or
            open instructions. The transaction must be provided unsigned, with
            the one-time wallet address set as the signer.
          type: string
        timestamp:
          description: >-
            Unix timestamp of when the position was opened (in milliseconds).
            Must be within 10 minutes of server time. Can be provided as a
            string or a number
          oneOf:
            - type: string
              pattern: ^[0-9]+$
            - type: integer
              format: int64
        user_signature:
          description: >-
            A digital signature of 'By signing, I hereby agree to Vanish's Terms
            of Service and agree to be bound by them
            (docs.vanish.trade/legal/TOS)


            Details:
            borrow:{smart_wallet_id}:{source_token_address}:{amount}:{loan_additional_sol}:{timestamp}:{jito_tip_amount}',
            signed by the user's wallet.
          type: string
    BorrowActionResponse:
      required:
        - action_id
        - tx_id
      type: object
      properties:
        action_id:
          description: Identifier of this lending or settle action.
          type: integer
          example: 88213
        tx_id:
          description: Transaction signature of the action. Poll it via /borrow/commit.
          type: string
        transaction:
          description: >-
            Base64-encoded signed transaction for you to broadcast. Null when
            Vanish submitted a Jito bundle instead; always populated for settle.
          type: string
          nullable: true
        jito_bundle_id:
          description: >-
            Bundle ID when the transaction was too large and Vanish submitted a
            two-transaction Jito bundle; otherwise null. When set, there is
            nothing to broadcast. Always null for settle.
          type: string
          nullable: true
    BorrowError:
      required:
        - error
      type: object
      properties:
        error:
          description: >-
            The error code or short description - the HTTP status text on
            endpoint errors, or the description itself on API key and rate limit
            errors.
          type: string
        message:
          description: >-
            The specific reason for the failure. Null on a signature
            verification failure, and absent on API key and rate limit errors -
            check it is present rather than assuming one error shape.
          type: string
          nullable: true
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.