Stream budget
A Stream budget makes a token amount available gradually, up to its funding limit and configured cap. Use it for recurring distributions or as the growing offer in a buyback auction. Funds stay in the DAO.sol contract.
Core concepts
- Availability: the amount the next run may use. Growth is bounded by the current treasury balance, its last recorded balance, and the configured cap.
- Rate and epoch:
amountPerEpochis the growth overepochIntervalseconds. An epoch is this interval; growth accrues throughout it. At 10 tokens per day, half a day adds 5. - Cap:
maxBudgetlimits availability. Zero removes the cap; supplied auction recipes require a nonzero cap to limit their offer. - Sync:
sync()updates the recorded balance and carries current availability forward. Use it after funding changes. - Checkpoint:
writeCheckpoint()records the balance and resets availability to zero. Use it to start or deliberately restart the stream; each successful flow checkpoints automatically.
Configuration
In a recipe builder, recipe is a Setup.InstallParams and usdc is an IERC20 reference. This streams 1 USDC per hour, capped at 10 USDC:
recipe.budget.id = bytes32("StreamBudget@1");
recipe.budget.settings = abi.encode(
usdc,
uint256(1_000_000), // amountPerEpoch: 1 USDC
uint256(10_000_000), // maxBudget: 10 USDC
uint256(1 hours) // epochInterval
);Amounts use raw token units. The interval must be positive; amountPerEpoch is at most type(uint128).max. Each instance belongs to one flow.
Checkpoint interface
Stream implements IBudget: available(caller, data) reads availability and ignores caller and data. Its commitActions() returns a checkpoint call for the DAO.sol contract to execute after success, including when some tokens were retained.
It also implements ICheckpointedBudget:
interface ICheckpointedBudget is IBudget {
/// @notice Restarts availability from zero and records the current balance.
/// @dev StreamBudget requires CHECKPOINT_PERMISSION_ID.
function writeCheckpoint() external;
}Setup grants the DAO.sol contract CHECKPOINT_PERMISSION_ID. Anyone may call sync().
Operate the stream
| Situation | What to do |
|---|---|
| Start | Include writeCheckpoint() in the installation proposal. Availability stays at zero until then. |
| Add funds | Send tokens to the DAO.sol contract, then call sync() to let the new funding support growth. |
| Spend through another proposal or flow | End that transaction with sync() to record the reduced balance. |
| Complete a run | The flow checkpoints automatically, starting the next accrual period from zero. |
Sync prevents funding changes from releasing a backlog. For example, a stream growing by 10 per day with only 30 funded stops at 30. A later deposit and sync resume growth from 30; a checkpoint would restart from zero.
Sync immediately after an outside spend: waiting until funds return can let availability jump when replenished. A sync during a temporary balance dip can slow growth. See the calculation for balance tracking and rounding.
Change settings and pause
The manager can call setAmountPerEpoch, setEpochInterval or setMaxBudget with SET_SETTINGS_PERMISSION_ID. Each setter syncs automatically. Rate changes preserve accrued availability; lowering the cap can reduce it.
Pausing stops execution, but availability continues growing up to the budget cap and funding limits. With a stream of 1 USDC/hour capped at 10 USDC, a sufficiently funded stream paused for 24 hours can offer 10 USDC immediately on resumption, still buying the same fixed token amount in an Open Fill buyback. Missed fills are not queued; the next successful run resets availability to zero.
To restart from zero, execute writeCheckpoint() and unpause() in the same governance transaction. This clears accrued availability without moving funds. sync() preserves current availability and does not clear it. The DAO.sol contract needs CHECKPOINT_PERMISSION_ID on the budget and PAUSE_PERMISSION_ID on the plugin; the supplied recipe grants the latter to the guardian, so governance must grant it to the DAO.sol contract before it can perform both calls.
See also
- Recurring buybacks: combine Stream with Open Fill and solvers.
- All budgets and Execution.
- Contract source and settings metadata.