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

# Quote a swap

> Estimate the output of a swap without building a transaction.

Returns the expected amount of `token_out` received for selling `amount_in`
of `token_in`, routed via 1inch. This is read-only: it does not build a
transaction, require an account, or check balances.

Use it to gauge exit liquidity and price impact for a token before entering
a position — for example, to warn when a market's underlying asset cannot be
swapped back to a stablecoin without large slippage.



## OpenAPI

````yaml /v2/combined_spec.json get /v2/earn/swap_quote
openapi: 3.1.0
info:
  title: Compass API
  description: Compass Labs DeFi API
  version: 0.0.1
servers:
  - url: https://api.compasslabs.ai
    description: Production server
security:
  - ApiKeyAuth: []
paths:
  /v2/earn/swap_quote:
    get:
      tags:
        - Earn
      summary: Quote a swap
      description: >-
        Estimate the output of a swap without building a transaction.


        Returns the expected amount of `token_out` received for selling
        `amount_in`

        of `token_in`, routed via 1inch. This is read-only: it does not build a

        transaction, require an account, or check balances.


        Use it to gauge exit liquidity and price impact for a token before
        entering

        a position — for example, to warn when a market's underlying asset
        cannot be

        swapped back to a stablecoin without large slippage.
      operationId: v2_earn_swap_quote
      parameters:
        - name: chain
          in: query
          required: true
          schema:
            type: string
            enum:
              - base
              - ethereum
              - arbitrum
              - hyperevm
              - tempo
              - bsc
            title: Chain
            description: The chain to use.
            default: base
          description: Target blockchain network.
        - name: token_in
          in: query
          required: true
          schema:
            type: string
            title: Token In
            default: WETH
          description: >-
            Token to sell (input). A token symbol (e.g. 'WETH') or any token
            address.
        - name: token_out
          in: query
          required: false
          schema:
            type: string
            default: USDC
            title: Token Out
          description: >-
            Token to buy (output). A token symbol (e.g. 'USDC') or any token
            address.
        - name: sy_address
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Sy Address
          description: >-
            Optional Pendle SY (Standardized Yield) address. When provided,
            `token_in` is overridden with the token the PT actually redeems into
            on withdrawal (the SY asset if it is a valid token-out, else the SY
            yield token) — use this to gauge a Pendle position's real exit
            liquidity rather than the reported underlying.
        - name: amount_in
          in: query
          required: true
          schema:
            anyOf:
              - type: number
                exclusiveMinimum: 0
              - type: string
                pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
            title: Amount In
            default: '1'
          description: Human-readable amount of `token_in` to quote (token units, not wei).
        - name: slippage
          in: query
          required: false
          schema:
            anyOf:
              - type: number
                minimum: 0
              - type: string
                pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
            default: '1.0'
            title: Slippage
          description: Maximum slippage tolerance as a percentage (e.g., 1 = 1%).
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EarnSwapQuoteResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      x-codeSamples:
        - lang: python
          label: Python (SDK)
          source: |-
            from compass_api_sdk import CompassAPI, models


            with CompassAPI(
                api_key_auth="<YOUR_API_KEY_HERE>",
            ) as compass_api:

                res = compass_api.earn.earn_swap_quote(chain=models.V2EarnSwapQuoteChain.BASE, token_in="WETH", amount_in="1", token_out="USDC", slippage="1.0")

                # Handle response
                print(res)
        - lang: typescript
          label: Typescript (SDK)
          source: |-
            import { CompassApiSDK } from "@compass-labs/api-sdk";

            const compassApiSDK = new CompassApiSDK({
              apiKeyAuth: "<YOUR_API_KEY_HERE>",
            });

            async function run() {
              const result = await compassApiSDK.earn.earnSwapQuote({
                chain: "base",
                tokenIn: "WETH",
                tokenOut: "USDC",
                amountIn: "1",
                slippage: "1.0",
              });

              console.log(result);
            }

            run();
components:
  schemas:
    EarnSwapQuoteResponse:
      properties:
        amount_out:
          type: string
          title: Amount Out
          description: >-
            Estimated amount of `token_out` received, in human-readable units.
            Zero when no route / insufficient liquidity exists for the pair.
        token_in:
          type: string
          title: Token In
          description: >-
            The token address actually quoted as input. Usually the requested
            `token_in`; for Pendle (when `sy_address` is supplied) it is the
            resolved redeem token, which callers should use to value the input.
        token_out:
          type: string
          title: Token Out
          description: >-
            The token address quoted as output — what `amount_out` is
            denominated in (the resolved `token_out` from the request).
      type: object
      required:
        - amount_out
        - token_in
        - token_out
      title: EarnSwapQuoteResponse
      description: Estimated output of a read-only swap quote.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        Your Compass API Key. Get your key
        [here](https://www.compasslabs.ai/dashboard).

````