DCA Create Order v0 API
Overview
This endpoint generates a transaction object for opening a Dollar-Cost Averaging (DCA) order. This includes creating an order transaction and handling insufficient token allowances by providing an approval transaction if needed.
💡
This API is rate-limited to 5 requests per 10 seconds per IP address.
Endpoint
https://api.swapscanner.io/v0/dca/order/tx
Query Parameters
maker(required): The address of the account creating the DCA order.beneficiary(optional): The address receiving the output tokens. Defaults to the maker's address if not provided.tokenIn(required): The address of the token being spent in the DCA order.amountInPerCycle(required): The amount of the input token to be spent per cycle, in smallest units.tokenOut(required): The address of the token being received.minAmountOutPerCycle(optional): The minimum amount of the output token to be received per cycle, in smallest units. Defaults to1.maxAmountOutPerCycle(optional): The maximum amount of the output token to be received per cycle, in smallest units. Defaults to the maximum allowable value.openBeforeTimestamp(optional): A timestamp indicating the latest time the order can be opened. The transaction will be reverted if the tx sent after this time. Must be in the future.cycleInterval(required): The interval between each cycle in seconds. Must be between60and31536000(1 year).totalCycles(required): The total number of cycles for the order.
⚠️
The amountInPerCycle must meet the minimum $1 USD equivalent threshold.
Response Structure
The endpoint returns a JSON object with the following properties:
openOrderTx(object): The transaction object for opening the DCA order.type(string): The type of transaction (openOrder).txs(object): The transaction details for various blockchain platforms, including:eth(object): Ethereum-specific transaction details.kaia(object): Kaia-specific transaction details.klip(object): Details for the Klip wallet integration.
error(object|null): Details about any error encountered. This will be null if no errors occurred.message(string): A description of the error (e.g., "insufficient input token allowance").tx(object): The transaction details needed to resolve the error (e.g., an approval transaction).type(string): The type of transaction (approve).txs(object): The transaction details for various blockchain platforms (similar toopenOrderTx).
Example
{
"openOrderTx": {
"type": "openOrder",
"txs": {
"eth": {
"from": "0x[MAKER_ADDRESS]",
"to": "0x[DCA_CONTRACT_ADDRESS]",
"data": "0xecb89bd8...",
"value": "0x0",
"type": "0x2",
"maxPriorityFeePerGas": "0x66720b300",
"maxFeePerGas": "0x66720b300"
},
"kaia": {
"from": "0x[MAKER_ADDRESS]",
"to": "0x[DCA_CONTRACT_ADDRESS]",
"data": "0xecb89bd8...",
"value": "0x0",
"type": "SMART_CONTRACT_EXECUTION",
"gasPrice": "0x66720b300"
},
"klip": {
"bappName": "Swapscanner",
"from": "0x[MAKER_ADDRESS]",
"to": "0x[DCA_CONTRACT_ADDRESS]",
"value": "0",
"abi": "{\"inputs\":[...]}",
"params": "[...]"
}
}
},
"error": {
"message": "insufficient input token allowance",
"tx": {
"type": "approve",
"txs": {
"eth": {
"from": "0x[MAKER_ADDRESS]",
"to": "0x42952b873ed6f7f0a7e4992e2a9818e3a9001995",
"data": "0x095ea7b3...",
"value": "0x0",
"type": "0x2",
"maxPriorityFeePerGas": "0x66720b300",
"maxFeePerGas": "0x66720b300"
},
"kaia": {
"from": "0x[MAKER_ADDRESS]",
"to": "0x42952b873ed6f7f0a7e4992e2a9818e3a9001995",
"data": "0x095ea7b3...",
"value": "0x0",
"type": "SMART_CONTRACT_EXECUTION",
"gasPrice": "0x66720b300"
},
"klip": {
"bappName": "Swapscanner",
"from": "0x[MAKER_ADDRESS]",
"to": "0x42952b873ed6f7f0a7e4992e2a9818e3a9001995",
"value": "0",
"abi": "{\"inputs\":[...]}",
"params": "[...]"
}
}
}
}
}Error Responses
400 Bad Request: Invalid or missing query parameters.429 Too Many Requests: Rate limit exceeded.500 Internal Server Error: An unexpected error occurred.
Notes
- Ensure the
amountInPerCyclemeets the minimum USD equivalent threshold. - If the token allowance is insufficient, an approval transaction will be included in the response under the
errorobject.