Keeper & indexed data

A keeper fills the slices the contract says are due. The hosted one also indexes every DCA event into a database, which the app reads first.

What a keeper can do

Any allowlisted address may call executeSlice when the verdict is ready, and closeExpired after a deadline. Nothing else: no withdrawals, no edits, and the contract re-checks every rule in the fill. Orders never depend on one keeper, because owners can fill their own slices.

ts
import { makeKeeper } from "@poincaretrade/api";

const pass = makeKeeper({ dcaAddress, privateKey: process.env.KEEPER_PRIVATE_KEY!, maxTx: 20 });
const run = await pass();
// { checked, executed: [{ id, amountIn, spreadBps }], refunded, held: { "spread-too-high": 2 }, deferred }

The contract owner adds or removes keepers with setKeeper(address, bool).

Indexed data

Public RPCs serve at most 1,000 blocks per log query, so history comes from an index: after each keeper pass the hosted dca-keeper function reads every PoincareDCA event since its cursor and writes two public, read-only tables.

TableOne row perMain columns
dca_ordersOrder (latest state)order_id, owner, side, status (open · completed · refunded · cancelled), paused, amount_in, spent, refunded, amount_out, fills, slices
dca_fillsExecuted sliceorder_id, owner, side, amount_in, amount_out, price, spread_bps, ts, tx_hash
Read order. Read the tables first; ask the chain only for open orders' live verdict and for the newest blocks the index has not reached. That is what the app does.

Running it yourself: see DCA.md (opens in a new tab) for the edge functions, secrets and the pg_cron schedule.

Unichain Sepolia · chain 1301 · testnetLaunch app