Cycle Lifecycle
Understanding the state machine that drives portfolio automation
A cycleis the protocol's long-lived execution state for a vault. It starts when a credit is consumed, remains open across multiple calls, and ends only when a close path succeeds or the vault owner explicitly exits.
Cycle Phases
1. Start
A new cycle begins when an allowed execution call reaches a vault with no active cycle. One owner credit is consumed, the opening portfolio state is recorded, and the vault's selected engine family/version is pinned for that cycle.
2. Active Rebalancing
During an active cycle, each allowed execution call evaluates the pinned engine module, applies any permitted trade path, refreshes the cycle snapshot, and then checks whether the cycle can close.
3. Close Eligibility
Close logic follows the vault's check mode. TOKEN0 mode closes on post-action net return in TOKEN0 terms, TOKEN1 mode closes in TOKEN1 terms, and Pair mode can close when either side reaches the limit.
4. Close & Rollover
If close conditions hold, the cycle either rolls into a new cycle or closes terminally. Terminal settlement behavior depends on the vault's check mode: mode 1 settles to TOKEN0, mode 2 settles to TOKEN1, and mode 3 leaves balances in place.
Close Reasons
| Code | Reason | Description |
|---|---|---|
| 1 | Rollover | Close conditions held and a new cycle started immediately. |
| 2 | Terminal | Close conditions held, but the cycle ended without rollover. |
| 3 | User Close | The vault owner used an exit action to close the active cycle. |
| 4 | Protective Close | A privileged protective action ended the cycle without a normal user exit. |