3Branches0Tags
GL
glucryptoSync production with master template updates
4d3cf1112 days ago23Commits
typescript
import type { DcaAgentConfig } from "../config"; import { executeDcaOrders } from "./execute-dca-orders"; export async function runDcaBot(config: DcaAgentConfig) { const dca = config.dca ?? { preset: "custom", symbols: [], slippageBps: 50, }; let execution: Record<string, unknown> | undefined; let executionError: string | null = null; if (config.execution?.enabled) { ({ execution, executionError } = await executeDcaOrders({ config, dca })); } if (executionError) { return { ok: false, error: executionError, asset: config.asset, signalType: "dca" as const, schedule: config.schedule, allocation: { mode: config.allocationMode, ...(config.amountUsd ? { amountUsd: config.amountUsd } : {}), }, dca: { preset: dca.preset, symbols: dca.symbols, slippageBps: dca.slippageBps, }, ...(execution ? { execution } : {}), }; } return { ok: true, asset: config.asset, signalType: "dca" as const, schedule: config.schedule, allocation: { mode: config.allocationMode, ...(config.amountUsd ? { amountUsd: config.amountUsd } : {}), }, dca: { preset: dca.preset, symbols: dca.symbols, slippageBps: dca.slippageBps, }, ...(execution ? { execution } : {}), }; }