Skip to main content

Overview

Integrating Recurring Buy involves managing the lifecycle of an order:
  1. Creation: Execute the recurring buy order transaction (Standard or Advanced).
  2. Monitoring: Fetch active orders to display in your UI.
  3. Cancellation: Allow users to close orders and retrieve remaining funds.

SDK Integration Flows

The SDK provides two methods for creating recurring buy orders, depending on your needs:

1. Standard Flow (executeCreateDca)

Use this for a simple, standalone recurring buy creation.
  • Handles everything: Automatically checks allowance, builds the approval transaction (if needed), and executes the recurring buy creation.
  • Best for: Standard UIs where the user just wants to “Create Order”.

2. Advanced Flow (createDcaToCalls)

Use this when you need to compose the recurring buy creation with other actions (multicall).
  • Returns Calls: Generates the necessary Starknet Call objects (including approval if needed).
  • Flexible: You can bundle these calls with other transactions (e.g., a swap or a deposit) and execute them atomically.
  • Best for: Complex flows, batching transactions, or using a custom account implementation.

1. Creating an Order

Use executeCreateDca to create the order. Ensure you import moment for the frequency.

2. Monitoring Orders

Use getDcaOrders to fetch a user’s orders. You can filter by status:
  • INDEXING - Order is being indexed after creation (temporary)
  • ACTIVE - Order is currently executing
  • CLOSED - Order completed or cancelled

3. Cancelling an Order

Users can cancel active orders to stop execution and retrieve unspent funds.