DCA API Documentation
Complete API reference for DCA.fun protocol endpoints
DCA API Documentation
This API provides endpoints for managing Dollar Cost Averaging (DCA) orders on blockchain networks using Chainlink Datastreams.
Base URL
https://api.dca.funAll endpoints should be prefixed with this base URL.
Endpoints
1. GET /createorder
Get the latest Chainlink Datastreams price report for creating a DCA order.
Query Parameters:
tokenFeedId(required) - The Chainlink feed ID for the token (32 byte hex string starting with0x)chainId(required) - The blockchain network ID (integer)
Response:
{
"unverifiedReport": ["0x..."],
"decodedReport": {
"version": "V3" | "V4",
"nativeFee": "string",
"linkFee": "string",
"expiresAt": "number",
"price": "string",
// V3 specific fields:
"bid": "string",
"ask": "string",
// V4 specific fields:
"marketStatus": "number"
}
}Example:
GET https://api.dca.fun/createorder?tokenFeedId=0x00037da06d56d083fe599397a4769a042d63aa73dc4ef57709d31e9971a5b439&chainId=84532. GET /pricetimestamp
Get a Chainlink Datastreams price report for a specific timestamp.
Query Parameters:
tokenFeedId(required) - The Chainlink feed ID for the token (hex string)timestamp(required) - Unix timestamp in seconds (10-digit integer)chainId(required) - The blockchain network ID (integer)
Response:
{
"decodedReport": {
"version": "V3" | "V4",
"nativeFee": "string",
"linkFee": "string",
"expiresAt": "number",
"price": "string",
// V3 specific fields:
"bid": "string",
"ask": "string",
// V4 specific fields:
"marketStatus": "number"
}
}Example:
GET https://api.dca.fun/pricetimestamp?tokenFeedId=0x00037da06d56d083fe599397a4769a042d63aa73dc4ef57709d31e9971a5b439×tamp=1704067200&chainId=84533. GET /quote
Get a quote for filling a specific DCA order, including Chainlink Datastreams price data and fillable amounts.
Query Parameters:
orderId(required) - The order ID (integer)chainId(required) - The blockchain network ID (integer)
Response:
{
"encodedData": "0x...",
"fillableAmount": "string",
"amountOfTokenOut": "string",
"scalingFactor": "string",
"tokenInPrice": "string",
"tokenOutPrice": "string"
}Response Fields:
encodedData- ABI-encoded data for the fill transactionfillableAmount- Amount of tokenIn that can be filled (BigInt as string)amountOfTokenOut- Expected amount of tokenOut to receive (BigInt as string)scalingFactor- Scaling factor used in calculations (BigInt as string)tokenInPrice- Current price of tokenIn (BigInt as string)tokenOutPrice- Current price of tokenOut (BigInt as string)
Example:
GET https://api.dca.fun/quote?orderId=42&chainId=84534. GET /active-orders
Get all active DCA orders that are ready to be filled on a specific chain.
Query Parameters:
chainId(required) - The blockchain network ID (integer)
Response:
{
"data": [
{
"id": 1,
"creator": "0x...",
"tokenIn": {
"address": "0x...",
"feed": "0x...",
"decimals": 18,
"symbol": "USDC",
"name": "USD Coin"
},
"tokenOut": {
"address": "0x...",
"feed": "0x...",
"decimals": 18,
"symbol": "ETH",
"name": "Ethereum"
},
"spendAmount": 1000000,
"slippage": 50,
"freqInterval": 86400,
"lastRun": 1704067200,
"nextRun": 1704153600
}
],
"count": 1
}Query Logic: Returns orders that meet ALL criteria:
- Not cancelled
- Next execution time has arrived (current time >= lastRun + freqInterval)
- Has at least 1 remaining repeat
- Ordered by slippage (descending)
Example:
GET https://api.dca.fun/active-orders?chainId=8453Error Responses
All endpoints use standard HTTP status codes:
400 Bad Request- Missing or invalid parameters500 Internal Server Error- Server or contract errors502 Bad Gateway- External service errors (Chainlink, RPC)
Common error patterns:
{
"error": "Missing required parameter: chainId"
}{
"error": "CALL_EXCEPTION: OrderNotFound"
}Code Examples
// Get a quote for filling an order
const response = await fetch(
'https://api.dca.fun/quote?orderId=123&chainId=8453'
);
const quote = await response.json();
console.log('Fillable amount:', quote.fillableAmount);
console.log('Output amount:', quote.amountOfTokenOut);
// Get active orders
const ordersResponse = await fetch(
'https://api.dca.fun/active-orders?chainId=8453'
);
const orders = await ordersResponse.json();
console.log(`Found ${orders.count} fillable orders`);import requests
# Get a quote for filling an order
response = requests.get(
'https://api.dca.fun/quote',
params={'orderId': 123, 'chainId': 8453}
)
quote = response.json()
print(f"Fillable amount: {quote['fillableAmount']}")
print(f"Output amount: {quote['amountOfTokenOut']}")
# Get active orders
orders_response = requests.get(
'https://api.dca.fun/active-orders',
params={'chainId': 8453}
)
orders = orders_response.json()
print(f"Found {orders['count']} fillable orders")# Get a quote for filling an order
curl "https://api.dca.fun/quote?orderId=123&chainId=8453"
# Get active orders
curl "https://api.dca.fun/active-orders?chainId=8453"
# Get price report for order creation
curl "https://api.dca.fun/createorder?tokenFeedId=0x00037da06d56d083fe599397a4769a042d63aa73dc4ef57709d31e9971a5b439&chainId=8453"Contract Address
The DCA contract uses the same address across all networks (mainnets and testnets):
0xDCA000935F1073df8e8235c1f577Fe0D81f69AF8WebSocket API
Real-time streaming of fillable orders at wss://api.dca.fun.
Features:
- Updates every 2 seconds
- Automatic filtering by chain
- Commands:
ping,refresh,filter
Connection Example:
const ws = new WebSocket("wss://api.dca.fun");
ws.onopen = () => {
// Filter for Base chain orders
ws.send(
JSON.stringify({
type: "filter",
chainId: 8453,
})
);
};
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
if (data.type === "update") {
console.log("Fillable orders:", data.orders);
}
};