Skip to main content

Track — Chainlink: Best workflow with CRE

Prize: $1.5k. Owner: snehendu098 (#31). Vault receiver: #29. (CCIP prize $3.5k is separate — not targeted. Check if one Chainlink pick covers both.)

Use in our stack​

CRE workflow = the rebalancer brain. Decides when vault goes HEDGED ⇄ FLAT.

Flow​

  1. Trigger: cron (1h prod, ~5 min demo).
  2. Read (external data): HTTP call → Arkiv arkiv_query for FundingRate entries per market in window.
    • Fallback: our gateway REST /funding.
    • Optional: CEX funding (e.g. Binance) as sanity benchmark.
  3. Decide:
    • Per market (BTC, ETH, HYPE, ZEC).
    • HEDGED + every funding print in last 3h < 0 → FLAT.
    • FLAT + latest funding > 0 → HEDGED.
    • Window configurable (short for demo).
    • Else no-op.
  4. Write (blockchain): EVM write → vault onReport(report) → setMode(market, mode, reasonRef) → emits ModeChanged.
  5. Execute: vault-keeper sees ModeChanged → runs legs:
    • Exit: close perp short first, then sell spot via v4 pool (avoid naked short).
    • Enter: buy spot first, then open short.

Why split: CRE can't sign our offchain CLOB orders. CRE = decision + onchain trigger. Keeper = execution.

Contract side​

  • Vault implements CRE receiver (onReport), only accepts calls from Chainlink Forwarder.
  • setMode guarded: only via onReport. Cooldown to prevent flapping.
  • reasonRef = Arkiv entity keys of funding entries used → links decision to public evidence.

Build steps​

  1. Install CRE CLI, start from CRE template (TS or Go).
  2. Workflow: cron → HTTP (Arkiv query) → decide → EVM write.
  3. Vault receiver contract + test.
  4. cre workflow simulate → show in demo. Deploy optional.

Qualification checklist​

  • CRE workflow used as orchestration layer in project.
  • Integrates ≥1 blockchain with external API/system/data source (Arkiv/gateway funding → vault).
  • Successful simulation via CRE CLI (or live deploy).
  • Meaningfully used (it is the rebalancer).