> ## 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.

# Refinance loan

> Update the duration of the loan.



## OpenAPI

````yaml post /markets/creditbook/refinance
openapi: 3.1.3
info:
  title: Loopscale API
  version: 1.0.0
servers:
  - url: https://tars.loopscale.com/v1
    description: Loopscale Production Server
security: []
paths:
  /markets/creditbook/refinance:
    post:
      tags:
        - Markets
      summary: Refinance loan
      description: Update the duration of the loan.
      operationId: refinanceLoan
      parameters:
        - name: user-wallet
          in: header
          required: true
          schema:
            type: string
          description: Wallet address of the borrowing user
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RefinanceLoanRequest'
      responses:
        '200':
          description: Serialized transaction
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LoanLockTransactionResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '500':
          $ref: '#/components/responses/GeneralError'
components:
  schemas:
    RefinanceLoanRequest:
      type: object
      required:
        - loan
        - oldStrategy
        - newStrategy
        - refinanceParams
      properties:
        loan:
          type: string
          description: Loan address to refinance
        oldStrategy:
          type: string
          description: Strategy address to refinance from.
        newStrategy:
          type: string
          description: >-
            Strategy address to refinance to, can be the same as old if just
            updating duration or start time.
        refinanceParams:
          type: object
          required:
            - ledgerIndex
            - durationIndex
          properties:
            ledgerIndex:
              type: integer
              description: Index of ledger to refinance (0–4)
            durationIndex:
              type: number
              description: >-
                Duration preset to refinance to. (0 = 1d, 1 = 1w, 2 = 1mo, 3 =
                3mo, 4 = 5min)
    LoanLockTransactionResponse:
      type: object
      properties:
        transactions:
          type: array
          items:
            type: object
            required:
              - message
              - signatures
            properties:
              message:
                type: string
                description: Base64-encoded versioned transaction message
              signatures:
                type: array
                items:
                  type: object
                  required:
                    - publicKey
                    - signature
                  properties:
                    publicKey:
                      type: string
                    signature:
                      type: string
        expectedLoanInfo:
          type: object
          description: Loan post transaction state used for verification
          properties:
            loan:
              type: object
              properties:
                address:
                  type: string
                  description: Onchain loan account
  responses:
    BadRequest:
      description: Bad Request
      content:
        text/plain:
          schema:
            type: string
            example: 'Something went wrong: You have an error in your SQL syntax.'
    GeneralError:
      description: General Server Error
      content:
        text/plain:
          schema:
            type: string
            example: >-
              Failed to deserialize the JSON body into the target type: missing
              field `mints` at line 1 column 1.

````