Skip to main content
GET
/
v2
/
earn
/
swap_quote
Python (SDK)
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)
{
  "amount_out": "<string>",
  "token_in": "<string>",
  "token_out": "<string>"
}

Authorizations

x-api-key
string
header
required

Your Compass API Key. Get your key here.

Query Parameters

chain
enum<string>
default:base
required

Target blockchain network. The chain to use.

Available options:
base,
ethereum,
arbitrum,
hyperevm,
tempo
token_in
string
default:WETH
required

Token to sell (input). A token symbol (e.g. 'WETH') or any token address.

token_out
string
default:USDC

Token to buy (output). A token symbol (e.g. 'USDC') or any token address.

sy_address
string | null

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.

amount_in
default:1
required

Human-readable amount of token_in to quote (token units, not wei).

Required range: x > 0
slippage
default:1.0

Maximum slippage tolerance as a percentage (e.g., 1 = 1%).

Required range: x >= 0

Response

Successful Response

Estimated output of a read-only swap quote.

amount_out
string
required

Estimated amount of token_out received, in human-readable units. Zero when no route / insufficient liquidity exists for the pair.

token_in
string
required

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
string
required

The token address quoted as output — what amount_out is denominated in (the resolved token_out from the request).