Guide

DCA (Dollar Cost Averaging) API Integration Documentation

Overview

This document provides comprehensive integration guidelines for the OpenOcean DCA (Dollar Cost Averaging) API, based on the implementation in Dca.js. The API allows users to create and manage automated recurring buy strategies for token accumulation on supported blockchain networks.

API Base Information

Base URL

Supported Networks

The DCA API supports the following blockchain networks:

Authentication & Wallet Integration

Prerequisites

  • MetaMask or compatible Web3 wallet

  • User must be connected to a supported network

  • User must have sufficient token balance and gas fees

  • Total allocation must be less than $5

Token Configuration

Token Approval

Before creating a DCA strategy, users must approve the contract to spend their tokens:

API Endpoints

1. Create DCA Strategy

Endpoint: POST /v2/{chainId}/dca/swap

URL Parameters:

  • chainId: The blockchain network ID (e.g., 8453 for Base)

Request Body:

Field Descriptions:

  • makerAsset: Address of the token being sold (e.g., USDC)

  • takerAsset: Address of the token being bought (e.g., USDT)

  • makerAmount: Total allocation amount in smallest units

  • signature: signMessage

  • orderMaker: User's wallet address

  • minPrice: Minimum price limit in USD (optional, 0 for no limit)

  • maxPrice: Maximum price limit in USD (optional, 0 for no limit)

  • time: Time interval between trades in seconds

  • times: Number of trades to execute

Response:

2. Cancel DCA Strategy

Endpoint: POST /v2/{chainId}/dca/cancel

Request Body:

Field Descriptions:

  • orderHash: Hash of the DCA strategy to cancel

  • signature: signMessage

Response:

3. Get User DCA Orders

Endpoint: GET /v2/{chainId}/dca/address/{address}

URL Parameters:

  • chainId: The blockchain network ID

  • address: User's wallet address

Query Parameters:

  • page: Page number (default: 1)

  • limit: Number of orders per page (default: 100)

  • statuses: Array of order statuses to filter [1,2,5]

  • sortBy: Sort field (default: createDateTime)

  • exclude: Exclude certain orders (default: 0)

Example URL:

Response:

Request/Response Formats

Order Status Codes

Code
Status
Description

1

Pending

DCA strategy is pending execution

2

Active

DCA strategy is active and executing trades

3

Filled

DCA strategy has completed all trades

4

Cancelled

DCA strategy has been cancelled

5

Expired

DCA strategy has expired

Message Signing Format

For DCA Strategy Creation:

For DCA Strategy Cancellation:

Signature Generation

Integration Examples

Complete DCA Strategy Creation Flow

DCA Strategy Management

Support

For technical support or questions about the API:

Last updated