Skip to main content

GET /api/dca/quote

Fetches a DCA swap quote from AVNU. Returns the expected BTC amount for a given token input.

Query Parameters

sell
string
required
Sell token address (e.g., ETH, USDC, USDT, STRK)
buy
string
required
Buy token address (always WBTC for DCA)
amount
string
required
Human-readable amount of sell token (e.g., “100” for 100 USDC)

Response

buyAmount
string
Expected BTC amount (human-readable, 8 decimals)
buyAmountUsd
number
USD value of BTC received
sellAmountUsd
number
USD value of tokens sold
priceImpact
number
Price impact percentage (e.g., 0.5 for 0.5%)
gasFeeUsd
number
Estimated gas fee in USD
route
string
Swap route taken (e.g., “Ekubo → AVNU”)

Example Request

curl "https://sable.money/api/dca/quote?sell=0x053c91...&buy=0x03fe2b...&amount=100"

Example Response

{
  "buyAmount": "0.00097534",
  "buyAmountUsd": 99.87,
  "sellAmountUsd": 100.00,
  "priceImpact": 0.13,
  "gasFeeUsd": 0.05,
  "route": "Ekubo → AVNU"
}

Token Addresses

Source: /home/daytona/workspace/source/src/app/api/dca/quote/route.ts:20 Supported tokens with decimals:
const DECIMALS = {
  "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7": 18, // ETH
  "0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8": 6,  // USDC
  "0x068f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8": 6,  // USDT
  "0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d": 18, // STRK
  "0x03fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac": 8,  // WBTC
};

Implementation Details

The DCA quote endpoint:
  1. Converts human-readable amount to raw smallest units based on token decimals
  2. Calls AVNU’s quote API with getAvnuQuote()
  3. Parses response and formats BTC amount to 8 decimals
  4. Returns formatted quote with price impact and route info
This is a read-only endpoint for display purposes. Actual DCA order creation happens on-chain via the DCA contract using the useDcaOrders() hook.

Smart DCA

The DCA contract supports Smart DCA using the Mayer Multiple indicator:
  • When BTC is below 0.8× its 200-day moving average → buy 1.5× normal amount
  • When 0.8-1.0× → buy 1.25× normal amount
  • When 1.0-1.5× → buy 1.0× normal amount (baseline)
  • When 1.5-2.0× → buy 0.75× normal amount
  • When above 2.0× → buy 0.5× normal amount
Smart DCA orders require 1.5× total deposit to cover maximum multiplier scenarios.

Build docs developers (and LLMs) love