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
  • Prerequisites
  • A) Protocol-Specific Approach (Explicit)
  • B) Protocol-Agnostic Approach (Less Explicit)
  • Next Steps
  1. Tutorial Guides
  2. Swaps
  3. EVM

How to get a quote

In this section, you'll learn how to request quotes for swapping between tokens.

Prerequisites

None

You can choose either the explicit path or the protocol-agnostic (less explicit) path to get quotes.

A) Protocol-Specific Approach (Explicit)

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

  1. Request Quote Fetch specific protocol information using:

    GET /strategies/:id/quote

    Required Parameters:

    Parameter
    Description
    Example

    chainId

    Blockchain network ID

    137 (Polygon)

    protocol

    Protocol name

    uniswap

    fromToken

    Token to swap from

    ETH

    toToken

    Token to swap to

    USDC

    amountIn

    Input amount

    1000000000000000000 (1 ETH with decimals)

    amountOut

    Output amount

    1820450000 (1820.45 USDC with decimals)

    slippage

    Maximum price slippage

    0.5 (0.5% slippage tolerance)

    deadline

    Transaction deadline

    1800 (30 minutes in seconds)

    Example Request:

    GET /strategies/3341412233111/quote?chainId=137&protocol=uniswap&fromToken=ETH&toToken=USDC&amountIn=1000000000000000000&amountOut=1820450000&slippage=0.5&deadline=1800

    Response:

    {
      "quote": {
        "expectedOutput": "1820450000",
        "estimatedGas": 150000,
        "priceImpact": "0.15"
      }
    }

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/quote

    Use the same parameters as above, excluding protocol.

    Example Request:

    GET /strategies/0x0/quote?chainId=137&fromToken=ETH&toToken=USDC&amount=1000000000000000000

    Response:

    {
      "quote": {
        "expectedOutput": "1820450000",
        "estimatedGas": 150000,
        "priceImpact": "0.15",
        "selectedProtocol": "uniswap"
      }
    }

The response includes:

  • expectedOutput: The amount of tokens you'll receive

  • estimatedGas: Estimated gas cost for the swap

  • priceImpact: The effect your trade will have on the price

  • selectedProtocol: (Only in protocol-agnostic response) The protocol selected for best execution

Next Steps

After getting a quote, you can:

PreviousHow to execute a swapNextSolana

Last updated 2 months ago

Execute the Swap