Create a DCA order
Creating Your First Order
Step-by-step guide to creating a DCA order on DCA.fun
Step 1: Choose Your Tokens
Select your input token (what you're spending) and output token (what you're buying).
struct OrderArgs {
address tokenIn; // e.g., USDC
address tokenOut; // e.g., WETH
// ... other parameters
}Step 2: Configure Order Parameters
Define your DCA strategy:
| Parameter | Description | Example |
|---|---|---|
spendAmount | Amount per execution | 100 USDC |
repeats | Number of executions | 52 (weekly for a year) |
freqInterval | Time between executions | 604800 (1 week) |
slippage | Maximum price deviation | 100 (1%) |
scalingInterval | Price improvement window | 86400 (1 day) |
Step 3: Enable Yield (Optional)
Choose whether to stake funds in Aave:
bool stakeAssetIn; // Earn yield on unspent funds
bool stakeAssetOut; // Earn yield on received tokensStep 4: Submit Transaction
// Approve token spending
await tokenIn.approve(dcaDotFun, totalAmount);
// Create order
await dcaDotFun.createOrder(orderArgs, priceReports);Example: Weekly Wrapped ETH Purchase
Let's create an order to buy $100 worth of ETH every week for a year:
const orderArgs = {
recipient: myAddress,
tokenIn: USDC_ADDRESS,
tokenOut: WETH_ADDRESS,
spendAmount: parseUnits("100", 6), // 100 USDC
repeats: 52, // 52 weeks
freqInterval: 604800, // 1 week in seconds
scalingInterval: 60, // 1 minute
slippage: 100, // 1%
firstExecution: 0, // Start in 1 week from now
stakeAssetIn: true, // Earn yield on USDC
stakeAssetOut: false, // Don't stake ETH
};
// Total amount needed: 100 USDC × 52 weeks = 5,200 USDC
const totalAmount = orderArgs.spendAmount * orderArgs.repeats;
// Approve and create order
await usdc.approve(dcaDotFun.address, totalAmount);
await dcaDotFun.createOrder(orderArgs, priceReports);Understanding Fees
- Order Fee: $0 (no cost)
- Protocol Fee: Paid by the filler, not the creator
- Yield Split: 20% of generated yield (if staking enabled)
- Gas Costs: Paid by the filler, not the creator