Deframe
  • 🏠Getting Started
  • 🏗️Architecture Overview
  • Tutorial Guides
    • Loans
      • How to quote for a new loan
      • How to execute a new loan
      • How to get current position of a loan
      • How to repay a loan
    • Yield
      • How to check protocol info
      • How to deposit
      • How to check open positions
      • How to withdraw
    • Swaps
      • EVM
        • How to execute a swap
        • How to get a quote
      • Solana
        • How to execute a swap
        • How to get a quote
  • ⚙️API
    • GET /strategies
    • GET /strategies/:id
    • GET /strategies/:id/bytecode
    • GET /wallets/:address
  • 🔒Protocols
  • 🗳️Widget Integration
Powered by GitBook
On this page
  • Overview
  • Two Integration Approaches
  • A) Protocol-Specific Approach (Explicit)
  • B) Protocol-Agnostic Approach (Less Explicit)
  • UI Integration Example
  • Next Steps
  1. Tutorial Guides
  2. Loans

How to quote for a new loan

Overview

Before implementing loan features in your application, you'll need to retrieve essential loan information such as interest rates, minimum collateral requirements, and other terms. This guide explains how to fetch this data using our Protocol Data API endpoints.

Two Integration Approaches

A) Protocol-Specific Approach (Explicit)

Use this when you want to work with a specific lending protocol.

  1. Get Available Protocols First, retrieve the list of all supported protocols:

    GET /strategies
  2. Query Protocol Details Then, fetch specific protocol information using:

    GET /strategies/:id

    Required Parameters:

    Parameter
    Description
    Example

    action

    Type of operation

    borrow

    chainId

    Blockchain network ID

    137 (Polygon)

    protocol

    Protocol name

    aave

    amount

    Borrow amount

    10000000 (with decimals)

    asset

    Asset to borrow

    USDC

    collateralAsset

    Collateral asset

    ETH

    collateralAmount

    Amount of collateral

    900000000000000000000000 (0.009 ETH with decimals)

    Example Request:

    GET /strategies/aave?action=borrow&chainId=137&protocol=aave&amount=10000000&asset=USDC&collateralAsset=ETH&collateralAmount=900000000000000000000000

    Response includes:

    • Current interest rate

    • Liquidation price

    • Loan-to-Value (LTV) ratio

    Example Response:

    {
      "status": "success",
      "data": {
        "protocol": "aave",
        "position": {
          "borrowAmount": "10000000",  // 10000000 with decimals
          "borrowAsset": "USDC",
          "collateralAmount": "900000000000000000000000",  // 0.009 ETH with decimals
          "collateralAsset": "ETH",
          "interestRate": "3.5",
          "liquidationPrice": "1850.00",
          "ltv": "75.5",
          "healthFactor": "1.85"
        },
        "marketConditions": {
          "maxLTV": "80.0",
          "liquidationThreshold": "82.5",
          "availableLiquidity": "1000000"
        }
      }
    }

B) Protocol-Agnostic Approach (Less Explicit)

Let our system automatically select the optimal protocol for your needs.

  1. Use the Generic Endpoint

    GET /strategies/0x0

    Use the same parameters as above, excluding protocol.

    Our system will analyze your requirements and return the best protocol option based on:

    • Lowest interest rates

    • Best LTV ratios

    • Current market conditions

    • Protocol reliability

UI Integration Example

Next Steps

After retrieving protocol information, you can proceed to:

PreviousLoansNextHow to execute a new loan

Last updated 3 months ago

Execute a loan
Manage loan positions
Example UI implementation showing protocol selection
Protocol Selection UI