Open Fill
Open Fill lets any solver permitted to trigger the flow take the offered tokens in exchange for delivering at least the configured amount of the requested token. It then passes the output to child actions. Combine it with a Stream budget for a growing offer, as in the recurring buyback example.
Core concepts
- Offer: the node's full input allocation, available for the solver to spend.
- Demand:
demandPerFill, the minimum amount ofdemandedTokentheDAO.solcontract must receive. - Solver: the contract that triggers the flow and completes the exchange when called back by the
DAO.solcontract.
flowchart LR
B["Stream budget"] -->|Growing USDC offer| O["Open Fill: solver fills for a fixed MYTOKEN demand"]
O -->|MYTOKEN| A["Next actions: burn, donate or split"]Choose the auction terms
Set the output token and demand in a recipe node. Here node is a Setup.RecipeNode and myToken is an IERC20 reference with 18 decimals:
node.action.id = bytes32("OpenFillAction@1");
node.action.settings = abi.encode(myToken, uint256(100e18));The demand must be positive and the demanded token must differ from the budget token. Setup supplies the flow's checkpointed budget as a dependency.
The maximum offer comes from the budget and any upstream split. For a root action, the stream's maxBudget bounds it. See buyback pricing for choosing the demand, rate and cap together.
Action interface and execution
Open Fill implements INodeAction:
build()returns the demanded output and three calls: approve the solver, call its exchange callback, then clear approval.preconditions()records the treasury's input- and output-token balances.- After the
DAO.solcontract executes the calls,postconditions()checks that at least the demand arrived and at most the offer was spent. Failure reverts the flow.
Children receive the declared demand. Enable forwardSurplus to send all received output through later steps.
Change demand or placement
Calling setDemandPerFill requires SET_SETTINGS_PERMISSION_ID on the action and restarts the whole budget from zero. Setup grants the action CHECKPOINT_PERMISSION_ID on its budget for this purpose.
Open Fill can sit below an action or splitter. The whole flow waits for a successful fill; use separate flows for branches needing independent schedules.
Solvers
See Build and run a Capital Tree solver for the callback interface, trigger data and supplied GenericFillSolver.
See also
- Recurring buybacks: the auction mechanism and a complete recipe.
- All actions and Execution.
- Contract source and settings metadata.