Overview
Integrating Recurring Buy involves managing the lifecycle of an order:- Creation: Execute the recurring buy order transaction (Standard or Advanced).
- Monitoring: Fetch active orders to display in your UI.
- 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
Callobjects (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
UseexecuteCreateDca to create the order. Ensure you import moment for the frequency.
2. Monitoring Orders
UsegetDcaOrders to fetch a user’s orders. You can filter by status:
INDEXING- Order is being indexed after creation (temporary)ACTIVE- Order is currently executingCLOSED- Order completed or cancelled