curl -X POST "https://starknet.api.avnu.fi/dca/v3/orders" \\
-H "Content-Type: application/json" \\
-d '{
"traderAddress": "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
"sellTokenAddress": "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
"sellAmount": "1000000000000000000",
"sellAmountPerCycle": "100000000000000000",
"buyTokenAddress": "0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8",
"frequency": "P1D",
"pricingStrategy": {
"tokenToMinAmount": null,
"tokenToMaxAmount": null
}
}'
// Create a DCA order to buy $100 USDC daily with ETH
const response = await fetch('https://starknet.api.avnu.fi/dca/v3/orders', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
traderAddress: account.address,
sellTokenAddress: ETH_ADDRESS,
sellAmount: ethers.parseEther("1"), // 1 ETH total
sellAmountPerCycle: ethers.parseEther("0.1"), // 0.1 ETH per day
buyTokenAddress: USDC_ADDRESS,
frequency: "P1D", // Daily
pricingStrategy: {
tokenToMinAmount: null, // No minimum (market order)
tokenToMaxAmount: null // No maximum
}
})
});
const { calls } = await response.json();
// Execute the calls to create the order
await account.execute(calls);
import requests
from datetime import datetime
# Create a weekly DCA order
order_data = {
'traderAddress': account_address,
'sellTokenAddress': ETH_ADDRESS,
'sellAmount': str(10**18), # 1 ETH total
'sellAmountPerCycle': str(10**17 * 25 // 100), # 0.25 ETH per week
'buyTokenAddress': STRK_ADDRESS,
'frequency': 'P1W', # Weekly
'startDate': datetime.now().isoformat(),
'pricingStrategy': {
'tokenToMinAmount': null, # No minimum (market order)
'tokenToMaxAmount': null # No maximum
}
}
response = requests.post(
'https://starknet.api.avnu.fi/dca/v3/orders',
json=order_data,
)
calls = response.json()['calls']
# Execute calls through your account
{
"chainId": "0x534e5f4d41494e",
"calls": [
{
"contractAddress": "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
"entrypoint": "approve",
"calldata": [
"0x073f6e3f2e5f8f8e7d3d2b1a0c9b8a7f6e5d4c3b2a1",
"0xde0b6b3a7640000",
"0x0"
]
},
{
"contractAddress": "0x073f6e3f2e5f8f8e7d3d2b1a0c9b8a7f6e5d4c3b2a1",
"entrypoint": "deploy_dca_order",
"calldata": [
"0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
"0xde0b6b3a7640000",
"0x16345785d8a0000",
"0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8",
"0x15180",
"0x0",
"0x1"
]
}
]
}
Recurring Buy
Create DCA Order
Generate calldata to create a dollar-cost averaging order on-chain
POST
/
dca
/
v3
/
orders
curl -X POST "https://starknet.api.avnu.fi/dca/v3/orders" \\
-H "Content-Type: application/json" \\
-d '{
"traderAddress": "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
"sellTokenAddress": "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
"sellAmount": "1000000000000000000",
"sellAmountPerCycle": "100000000000000000",
"buyTokenAddress": "0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8",
"frequency": "P1D",
"pricingStrategy": {
"tokenToMinAmount": null,
"tokenToMaxAmount": null
}
}'
// Create a DCA order to buy $100 USDC daily with ETH
const response = await fetch('https://starknet.api.avnu.fi/dca/v3/orders', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
traderAddress: account.address,
sellTokenAddress: ETH_ADDRESS,
sellAmount: ethers.parseEther("1"), // 1 ETH total
sellAmountPerCycle: ethers.parseEther("0.1"), // 0.1 ETH per day
buyTokenAddress: USDC_ADDRESS,
frequency: "P1D", // Daily
pricingStrategy: {
tokenToMinAmount: null, // No minimum (market order)
tokenToMaxAmount: null // No maximum
}
})
});
const { calls } = await response.json();
// Execute the calls to create the order
await account.execute(calls);
import requests
from datetime import datetime
# Create a weekly DCA order
order_data = {
'traderAddress': account_address,
'sellTokenAddress': ETH_ADDRESS,
'sellAmount': str(10**18), # 1 ETH total
'sellAmountPerCycle': str(10**17 * 25 // 100), # 0.25 ETH per week
'buyTokenAddress': STRK_ADDRESS,
'frequency': 'P1W', # Weekly
'startDate': datetime.now().isoformat(),
'pricingStrategy': {
'tokenToMinAmount': null, # No minimum (market order)
'tokenToMaxAmount': null # No maximum
}
}
response = requests.post(
'https://starknet.api.avnu.fi/dca/v3/orders',
json=order_data,
)
calls = response.json()['calls']
# Execute calls through your account
{
"chainId": "0x534e5f4d41494e",
"calls": [
{
"contractAddress": "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
"entrypoint": "approve",
"calldata": [
"0x073f6e3f2e5f8f8e7d3d2b1a0c9b8a7f6e5d4c3b2a1",
"0xde0b6b3a7640000",
"0x0"
]
},
{
"contractAddress": "0x073f6e3f2e5f8f8e7d3d2b1a0c9b8a7f6e5d4c3b2a1",
"entrypoint": "deploy_dca_order",
"calldata": [
"0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
"0xde0b6b3a7640000",
"0x16345785d8a0000",
"0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8",
"0x15180",
"0x0",
"0x1"
]
}
]
}
Overview
Creates a DCA (Dollar-Cost Averaging) order that automatically executes recurring swaps at specified intervals. Each order is deployed as a dedicated smart contract that manages your funds and executes trades autonomously.Request
string
required
Address that will own the DCA order
string
required
Token to sell over time
string
required
Total amount to sell across all cycles
string
required
Amount to sell in each cycle
string
required
Token to purchase
string
required
ISO 8601 duration format (e.g., “P1D” for daily, “PT12H” for 12 hours)
PT1H- Every hourPT6H- Every 6 hoursP1D- DailyP1W- WeeklyP1M- Monthly
string
ISO 8601 start date (defaults to now)
object
required
Response
string
required
Network identifier (e.g., “0x534e5f4d41494e”)
array
required
curl -X POST "https://starknet.api.avnu.fi/dca/v3/orders" \\
-H "Content-Type: application/json" \\
-d '{
"traderAddress": "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
"sellTokenAddress": "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
"sellAmount": "1000000000000000000",
"sellAmountPerCycle": "100000000000000000",
"buyTokenAddress": "0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8",
"frequency": "P1D",
"pricingStrategy": {
"tokenToMinAmount": null,
"tokenToMaxAmount": null
}
}'
// Create a DCA order to buy $100 USDC daily with ETH
const response = await fetch('https://starknet.api.avnu.fi/dca/v3/orders', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
traderAddress: account.address,
sellTokenAddress: ETH_ADDRESS,
sellAmount: ethers.parseEther("1"), // 1 ETH total
sellAmountPerCycle: ethers.parseEther("0.1"), // 0.1 ETH per day
buyTokenAddress: USDC_ADDRESS,
frequency: "P1D", // Daily
pricingStrategy: {
tokenToMinAmount: null, // No minimum (market order)
tokenToMaxAmount: null // No maximum
}
})
});
const { calls } = await response.json();
// Execute the calls to create the order
await account.execute(calls);
import requests
from datetime import datetime
# Create a weekly DCA order
order_data = {
'traderAddress': account_address,
'sellTokenAddress': ETH_ADDRESS,
'sellAmount': str(10**18), # 1 ETH total
'sellAmountPerCycle': str(10**17 * 25 // 100), # 0.25 ETH per week
'buyTokenAddress': STRK_ADDRESS,
'frequency': 'P1W', # Weekly
'startDate': datetime.now().isoformat(),
'pricingStrategy': {
'tokenToMinAmount': null, # No minimum (market order)
'tokenToMaxAmount': null # No maximum
}
}
response = requests.post(
'https://starknet.api.avnu.fi/dca/v3/orders',
json=order_data,
)
calls = response.json()['calls']
# Execute calls through your account
{
"chainId": "0x534e5f4d41494e",
"calls": [
{
"contractAddress": "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
"entrypoint": "approve",
"calldata": [
"0x073f6e3f2e5f8f8e7d3d2b1a0c9b8a7f6e5d4c3b2a1",
"0xde0b6b3a7640000",
"0x0"
]
},
{
"contractAddress": "0x073f6e3f2e5f8f8e7d3d2b1a0c9b8a7f6e5d4c3b2a1",
"entrypoint": "deploy_dca_order",
"calldata": [
"0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
"0xde0b6b3a7640000",
"0x16345785d8a0000",
"0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8",
"0x15180",
"0x0",
"0x1"
]
}
]
}
Order Calculation
Number of cycles = Total Amount ÷ Amount Per CycleDuration = Number of Cycles × FrequencyExample: 1 ETH total, 0.1 ETH per cycle, daily frequency = 10 days duration
Was this page helpful?
⌘I