Actions
Actions define what the plugin does at each step of a capital flow: swap, transfer, burn, retain or donate tokens. Each action uses its node's allocation to prepare calls for the DAO.sol contract to execute and checks their result.
Building and checking a node
The plugin runs each action in this order:
- Build calls. The action prepares the operations and declares the expected output.
- Capture initial state. The action checks prerequisites and records what it needs to verify the result, such as a recipient's starting balance.
- Execute. The
DAO.solcontract makes the calls using its funds and authority. - Check results. The action verifies the intended effect, and the plugin checks token balances.
- Continue to children. The plugin passes the output to the next nodes, dividing it through a splitter where needed.
The action's methods are read-only. Any failed check reverts the flow. See Execution for how the whole run fits together.
Core concepts
- Input and output: an
Assetdescribes the token and amount at each step. Input is the node's allocation; output is the minimum it declares for its children. Leaves declare zero output. - Calls: an
Action[]contains the target, value and calldata for each call theDAO.solcontract executes. Node actions build these calls. - Caller and data:
callertriggered the flow;datais this node's entry in the supplied node-data array. - Snapshot: bytes captured before execution, such as a recipient's balance, for checking the result afterward.
The node action interface
INodeAction uses IBudget, Asset and Action:
solidity
interface INodeAction {
/// @return The required budget, or address zero when unbound.
function budget() external view returns (IBudget);
/// @notice Builds the node's calls and declares their expected output.
/// @param caller The address that triggered the flow.
/// @param data This node's entry in the trigger data.
/// @param input The token and amount assigned to this node.
/// @return output Minimum output for children; zero amount for a leaf.
/// @return actions Calls executed through the DAO.sol contract.
function build(address caller, bytes calldata data, Asset calldata input)
external view returns (Asset memory output, Action[] memory actions);
/// @notice Checks prerequisites after build and before executing the calls.
/// @return snapshot Initial state and context needed by postconditions.
function preconditions(
address caller, bytes calldata data, Asset calldata input, Asset calldata output
) external view returns (bytes memory snapshot);
/// @notice Reverts if the executed calls did not produce the required result.
/// @param snapshot State captured by preconditions, including any needed node-data context.
function postconditions(
address caller, Asset calldata input, Asset calldata output, bytes calldata snapshot
) external view;
}Choose an action
| Action | Result |
|---|---|
| Open Fill | Exchanges its input for a fixed demand and passes output to children |
| Transfer | Pays a fixed recipient |
| Transfer to Beneficiary | Pays an address supplied by the caller |
| Burn | Burns its allocation |
| Keep | Retains its allocation in the DAO.sol contract |
| Vault Donate | Adds vault assets without minting shares |
All except Open Fill are leaves. See Keep's implementation for a minimal action and component setup for initialization and grants.