Strimz
Self-hosting

Self-hosting the agent

The AutoPay Agent process.

The agent is a Nest cron app + BullMQ worker. It runs scheduled jobs (recovery emails, cashflow digests, anomaly detection, monthly reports) and consumes the routing queue for CCTP V2 bridging.

Build

cd apps/agent
pnpm build
pnpm start:prod

Configuration

NODE_ENV=production
PORT=4300
DATABASE_URL=postgresql://...
REDIS_URL=redis://...

ARC_ENVIRONMENT=mainnet
ARC_RPC_URL=https://your-arc-rpc.com

# Cron schedules
RECOVERY_TICK_CRON=0 0 * * * *
CASHFLOW_DIGEST_CRON=0 0 9 * * *
CASHFLOW_ANOMALY_CRON=0 0 * * * *
CASHFLOW_YIELD_CRON=0 30 9 * * *
COMMERCE_MONTHLY_CRON=0 0 9 1 * *
PRICING_MONTHLY_CRON=0 0 9 1 * *

# Anomaly thresholds (standard deviations)
ANOMALY_THRESHOLD_LOW=3.0
ANOMALY_THRESHOLD_MEDIUM=2.0
ANOMALY_THRESHOLD_HIGH=1.0

# CCTP V2 attestation API
CIRCLE_ATTESTATION_BASE_URL=https://iris-api.circle.com  # or sandbox for testnet
CIRCLE_API_KEY=                                          # optional; for higher rate limits

# Email
RESEND_API_KEY=...
RESEND_FROM_EMAIL=noreply@your-domain.com

What runs when

CapabilityCronNotes
recoveryhourlyIdempotent per (subId, attempt)
cashflow.digestdaily 9am UTCIdempotent per UTC day
cashflow.anomalyhourlyz-score over trailing 30d
cashflow.yielddaily 9:30am UTCRecommendation only. No signing.
commercefirst of each monthPer-month dedup
pricing_intelligencefirst of each monthPer-month dedup
routingqueue-drivenCCTP V2 attestation polling

The agent reads AgentMerchantConfig on every tick, so config changes in the dashboard take effect on the next firing.

Single-instance recommendation

Unlike the scheduler, the agent has no built-in multi-instance safety. Two agent instances will fire each cron twice. The dedup logic inside each capability stops the visible side effects from duplicating (the same email won't be sent twice inside the dedup window), but you're burning compute for nothing.

If you need horizontal scale for the routing worker (high CCTP volume), run one cron instance and several routing-only workers configured through BullMQ.concurrency.

Observability

  • /healthz, /readyz
  • Activity log written to AgentActivityLog for every action
  • AuditLog entries for cashflow.anomaly_detected, merchant.fee_bps_changed_onchain, fees.accrued

Failure modes

  • Resend API outage. Emails fail. The agent retries on the next tick. No state is lost.
  • Circle attestation outage. Routing jobs back up in the queue. The agent re-polls until Circle responds.
  • Postgres outage. Capabilities skip. The next tick retries.

Source

github.com/StrimzLab/strimz/tree/main/apps/agent

On this page