# Jobs & rounds

> How forecast jobs are created and gated, which markets they may trade, what a round carries on-chain, and how a vault's engine reads it.

Source: https://docs.degenhive.ai/forecasters/jobs-and-rounds

A **forecast job** is a stream of rounds that one vault trades. A **round** is an on-chain attestation in `HyperSignalBook`: a sealed commitment to the round's forecasts (`forecastsRoot`) plus sparse target weights, in basis points, for the markets the job covers. Individual forecasts and forecaster identities never go on-chain.

## Two kinds of job

| | Verified job (Mode 1) | Manager job (Mode 2) |
|---|---|---|
| Created by | The council | The vault's live manager, or the council |
| Rounds posted by | The protocol poster (or the council) | The manager, its custom scorer, or the council |
| Scored and paid by | The protocol scorer | The manager or its custom scorer |
| Pots | USDC; DGV too at token launch | USDC only |
| Slashing | Protocol scorer and council | Manager can only propose; the protocol executes |
| Paid days counted | Yes (`paidDaysCount`) | No |

**Job 1 is the Flagship job.** It exists from deployment, has no vault, and runs a 24-hour horizon on a 4-hour cadence. Every other job is bound to one vault. A vault's manager is resolved live: the vault's `strategyManager()`, else its `admin()`. If a vault changes manager, a custom scorer set by the previous manager stops counting.

## Create a job

```solidity
function createJob(
    address vault,
    bool verified,
    address customScorer,
    uint32 horizonSecs,
    uint32 cadenceSecs,
    string calldata specUri,
    JobEntryFilter calldata filter
) external returns (uint64 jobId);

struct JobEntryFilter {
    uint128 minBondUsdc;       // raises the global minimum; 0 = global only
    uint16 maxRecentSlashBps;  // 0 = no limit
    uint32 minPaidDays;        // paid days on verified jobs
    uint32 minBondAgeSecs;     // since the bond first met the global minimum
    bool whitelistOnly;        // only addresses set with setJobWhitelist
}
```

| Parameter | Rule |
|---|---|
| `vault` | Non-zero; a factory vault or one the council allowed |
| `verified` | `true` only from the council; verified jobs ignore `customScorer` |
| `horizonSecs` | 1 hour to 7 days; fixed for the job's life |
| `cadenceSecs` | At most 7 days; fixed for the job's life |
| `specUri` | Non-empty. The job's own description of what to predict and how it scores |
| `filter.maxRecentSlashBps` | At most 10,000 |

Job ids start at 2 and count up (`nextJobId()` returns the last one created). Reverts: `ZeroAddress`, `Unauthorized` (caller is not the council or the vault's manager, or a non-council caller sets `verified`), `VaultNotAuthorized(vault)`, `InvalidPolicy`.

The owner can later call `updateJob(jobId, customScorer, specUri, filter, active)` to change the scorer (manager jobs only), the spec, the filter or the active flag, and `setJobWhitelist(jobId, forecasters, allowed)` to manage a private list. Horizon, cadence, vault and `verified` never change.

A vault trades a job through the `forecastJobId` in its fee config: job `1` or a job bound to that vault. With `forecastJobId == 0` the engine reads job 1. [Vault fees](https://docs.degenhive.ai/vaults/fees.md) covers the forecast share that funds the job's pot.

> [!TIP]
> Read a job's `specUri` before you forecast for it. The contract stores the string as given; the job owner decides what it points to.

## Markets

The council lists the markets that rounds may target, up to 256. Each market has a sleeve (`0` core perp, `1` HIP-3 perp on `trade.xyz`), a curated weight cap, its size decimals, and a pause flag. A round can only target listed, unpaused markets.

Asset ids follow HyperCore: a core perp uses its index in the perp universe, and a HIP-3 perp uses `100000 + dex × 10000 + index`.

**viem**

```ts
const abi = parseAbi([
  "function marketCount() view returns (uint256)",
  "function marketIds(uint256 index) view returns (uint32)",
  "function markets(uint32 assetId) view returns (bool listed, bool paused, uint8 sleeve, uint16 maxWeightBps, uint8 szDecimals)",
]);
const n = await pub.readContract({ address: SIGNAL_BOOK, abi, functionName: "marketCount" });
for (let i = 0n; i < n; i++) {
  const id = await pub.readContract({ address: SIGNAL_BOOK, abi, functionName: "marketIds", args: [i] });
  const [listed, paused, sleeve, maxWeightBps] = await pub.readContract({
    address: SIGNAL_BOOK, abi, functionName: "markets", args: [id],
  });
  console.log(id, { listed, paused, sleeve, maxWeightBps });
}
```

**REST**

```bash
curl -s https://api.degenhive.ai/v1/vaults/markets | jq   # asset universe and perp dexes
```

## What a round carries

```solidity
function postJobRound(
    uint64 jobId,
    uint32 horizonSecs,
    uint64 ttlSecs,
    uint16 regimeStormBps,
    uint32 forecasterCount,
    bytes32 forecastsRoot,
    uint32[] calldata assetIds,
    int16[] calldata targetWeightsBps
) external returns (uint64 roundId);
```

| Field | Meaning | Bound |
|---|---|---|
| `horizonSecs` | How far ahead this round predicts | 1 hour to 7 days |
| `ttlSecs` | How long the targets stay fresh; `expiresAt = postedAt + ttlSecs` | Above 0, at most 7 days |
| `regimeStormBps` | A market-stress reading attached to the round | At most 10,000 |
| `forecasterCount` | How many forecasts went into the round | Attested, not checked |
| `forecastsRoot` | Commitment to every forecast in the round | Non-zero |
| `assetIds`, `targetWeightsBps` | Sparse target weights, signed, in bps of the vault | Listed, unpaused, no duplicates, no zero weight |

Verified jobs are posted by the protocol poster or the council; manager jobs by the manager, its live custom scorer or the council. Reverts: `JobNotFound`, `JobNotActive`, `Unauthorized`, `InvalidPolicy`, `LengthMismatch`, `MarketNotListed`, `MarketPaused`, `DuplicateMarket`, `ZeroAmount` (a zero weight). Each round emits `JobRoundPosted` with every field.

The contract keeps only the latest round's metadata (`jobLatestRound`) and every round's weights (`jobRoundTargetBps(jobId, roundId, assetId)`). `roundId` counts up per job from 1. Nothing on-chain enforces the cadence, and a round's horizon need not equal the job's.

## How engines read a round

A vault's engine steps each market toward the latest round of its job, while that round is fresh:

1. Read `jobLatestRound(job)`. If `block.timestamp > expiresAt`, the target is 0 and the engine steps the market to flat.
2. Otherwise read `jobRoundTargetBps(job, roundId, assetId)`. Markets the round omits have target 0.
3. Clamp the target to the vault tier's cap for that market; Flagship vaults also apply the market's `maxWeightBps`.

`jobTargetWeightOf(jobId, assetId)` returns the same live answer in one call, as `(weightBps, regimeStormBps, fresh)`. Use it to see what a vault is trading toward. The engine does not read `regimeStormBps`.

## The UTC grid

Pay runs on UTC days: `HyperCrowdPay.today()` is `block.timestamp / 86400`, and each job has one pot per day. The protocol poster runs verified jobs on a UTC grid: with cadence `c`, slot `k` opens at `k × c` seconds after the Unix epoch, so the Flagship's 4-hour cadence posts at 00:00, 04:00, 08:00 and so on, UTC. The grid is a poster convention. On-chain, `roundId` is a per-job counter, not the slot number.

> **Figure: Rounds on the UTC grid.** A job's rounds start at multiples of its horizon; each round steers the engine while it is the newest fresh round and is scored once its horizon ends.
>
> A UTC axis for an example 4-hour job, with ticks at 00:00, 04:00, 08:00, 12:00 and 16:00 and four rounds between them: round r − 1, round r (highlighted), round r + 1 and round r + 2. At 04:00 an arrow marks postJobRound, which commits forecastsRoot and target weights and sets expiresAt. At 08:00 a second arrow marks the end of round r's horizon, when round r is scored. A bar under round r shows the engine trading on it while it is the newest fresh round; a dashed tail continues to expiresAt, until which round r stays usable if no newer round posts. The TTL is at most 7 days. Horizons run from 1 hour to 7 days.

Use the decoder to find the current slot and its start time for a cadence, and to convert a percentage weight into bps.

> **Interactive simulator (HyperSignalBook round slot and bps encoder):** UTC round slot `floor(unixSeconds / horizonSecs)` for horizons of 1 hour to 7 days (`3600`..`604800`), and the CrowdPay pot day `floor(unixSeconds / 86400)`. The on-chain `roundId` is a per-job counter. Encodes percent to basis points `round(pct * 100)`: target weights are `int16` (non-zero), and the engine clamps each to `±min(cap, 10000)`; `regimeStormBps` is `0`..`10000`.

Forecasts for a slot must be in before it opens. A forecast posted publicly before its round starts can be copied, which costs you originality in [scoring](https://docs.degenhive.ai/forecasters/scoring.md).

## Related

- [Forecaster quickstart](https://docs.degenhive.ai/forecasters.md) Bond, bind a hot key and check eligibility.
- [Scoring](https://docs.degenhive.ai/forecasters/scoring.md) How the round's forecasts are graded and combined.
- [Bonds & pay](https://docs.degenhive.ai/forecasters/bonds-and-pay.md) How USDC bonds, daily pots and probation payouts work.
- [Writing a model](https://docs.degenhive.ai/forecasters/writing-a-model.md) Produce sparse int16 weights for these rounds.
