Skip to Content

Builder

What each function of the builder does, who may call it, when, and what it checks.

Builder. The builder holds only its registry, fixed in its bytes, and keeps no record of what it made: member i of configuration c owned by owner lives at CREATE2(builder, keccak256(abi.encode(owner, keccak256(abi.encode(c)), i)), initCodeHash), initCodeHash being the member proxy’s init-code hash, the same computation on every chain, and MemberCreated announces it. A configuration names a kind, a profile, each member’s exact release and each member’s kernel release (one VERSION entry id of each per member, on that member’s chain; the kernel’s on the kernel line), so the owner’s configuration fixes the code and the kernel every member starts on, and a member changes kernel afterwards only by its owner’s switch; the kind lists one member or more (each index fits a byte), each on the chain it names, member 0 the hub (no chain is special: the hub lives where its kind says); the builder sets no other shape, each member’s logic deciding which kinds it serves (its place, its type, how many members), and member i’s named release must be an open entry of its line, keccak256(abi.encode(kind, i)). On the hub’s chain, create is the owner’s own transaction, carrying the owner’s signature of Create(configHash, run): the configuration and its first run, run 1, naming the hub and every leg in the kind’s order at owner generation 0. The kind and the profile must be listed and open, every local member’s named release and named kernel must be their lines’ newest, and the run’s group must have an execution key and not be stopped. A kind with a member off the hub’s chain takes only the owner’s ECDSA signature, so such a strategy is owned only by a key that can sign on every chain; a kind on one chain takes ECDSA or the owner’s ERC-1271 there. It creates the local members, initialises the legs, relays the run and its signature to each of them (each leg checks and records it), reads the funding token from the hub’s named logic (fundingToken(), its chain’s USDC; the kernel checks that logic’s code when it initialises the hub), tries the owner’s permit on it, moves exactly amount from the owner to the hub and only then initialises the hub, which starts funded. On every other chain, anyone completes the strategy with createRemote, each member on exactly its named release and named kernel, both open on that chain (a release listed since changes nothing; one retired since is refused); a kind or profile retired since the creation does not stop it; the creation’s run and signature are then relayed to each leg made there. Any member’s refusal reverts the whole call.

The other contracts, and every caller on one table, are on the overview.

The owner’s wallet

The member’s owner, one wallet (a Safe included), calling it directly, and nothing else.

create

function create(
    StrategyConfig calldata c,
    uint256 amount,
    OwnerMessages.Run calldata run,
    Permit calldata p,
    bytes calldata createSig
) external returns (address hub)

Creates a strategy on its hub’s chain and funds it: every local member at its address, the legs initialised, the creation’s run relayed to each of them with the owner’s signature (each records run 1 in its group), the funding token read from the hub’s named logic, the owner’s permit on it tried (a failure is ignored: anyone may have submitted it first), exactly amount moved from the owner to the hub, then the hub initialised with that amount and the run’s group, so its first run starts funded. Returns the hub’s address.

Who may call: The owner’s wallet: the owner is the sender.

When: On the hub’s chain, once per owner and configuration.

Parameters

NameTypeDescription
cStrategyConfigThe strategy’s configuration (StrategyConfig).
amountuint256The funding token the hub starts with, in its units (USDC: 6 decimals).
runOwnerMessages.RunThe creation’s run (OwnerMessages.Run): run 1 in the execution group DLTX’s app picked, naming every leg at generation 0.
pPermitThe owner’s permit for the builder on the funding token (Permit); a zero deadline for none.
createSigbytesThe owner’s signature of Create(configHash, run), relayed to every leg as its run’s signature.

What it checks

  • The amount is not zero (ZeroAmount), the run’s group has an execution key (NoKey) and the registry has not stopped it (GroupStopped).
  • The configuration names this builder and a kind of one member or more, each index fitting a byte, one parameter block and one release each (BadConfig); the kind and the profile are listed and not retired (NotListed).
  • Every local member’s named release is an open VERSION entry of its line (NotListed), numbered above 0 and its line’s newest (NotNewest).
  • This is the hub’s chain (WrongChain).
  • run is run 1, its deadline not passed, naming the hub and every leg in the kind’s order on its chain at owner generation 0 (BadRun).
  • createSig is the sender’s signature over Create(configHash, run) in the owner’s EIP-712 domain: ECDSA for a kind with a member off the hub’s chain, ECDSA or ERC-1271 for a kind on one chain (BadSignature).
  • No member exists yet at its address (AlreadyCreated), and each lands there (DeployFailed).
  • Each member’s initialisation and each leg’s record of the run accept (their own reasons), and the token’s transfer from the owner succeeds (its reason).

Anyone

Any address. These functions take no recipient and act only as the code allows: they move nothing anywhere the owner did not choose.

createRemote

function createRemote(
    address owner,
    StrategyConfig calldata c,
    uint256 index
) external returns (address member)

Creates and initialises one member of the strategy owner created on its hub’s chain, the member at index, which lives on this chain, on exactly the release its configuration names, and returns its address. One member a call, so every creation fits half the smallest block of the chain it runs on however many members the chain holds. Its address commits to the owner and the configuration, so this grants nothing; a member made for a configuration no one created holds nothing and obeys only its owner. A leg made here records its run from the owner’s signed creation run, relayed afterwards by anyone.

Who may call: Anyone (DLTX, or the owner).

When: On any chain other than the hub’s that has a member of the kind, once per member, owner and configuration.

Parameters

NameTypeDescription
owneraddressThe owner who created the strategy on its hub’s chain.
cStrategyConfigThe strategy’s configuration (StrategyConfig).
indexuint256The member to create, in the kind’s order: a leg on this chain.

What it checks

  • This is not the hub’s chain, and member index lives on this chain (WrongChain); the owner is not zero (BadConfig).
  • The configuration names this builder and a kind of one member or more, each index fitting a byte, one parameter block and one release each, and index is one of them (BadConfig); the kind and the profile were listed, retired since or not (NotListed).
  • The member’s named release is an open VERSION entry of its line on this chain, listed and not retired (NotListed), numbered above 0 (NotNewest); a newer release listed since changes nothing.
  • No member exists yet at its address (AlreadyCreated), and it lands there (DeployFailed); its initialisation accepts (its own reasons).

Read-only

Views and constants: they change nothing, and anyone may read them.

proxyImplementation

function proxyImplementation() external view returns (address k)

What a member’s proxy asks for while the builder creates it: the kernel its owner’s configuration names for it, checked. Outside a creation it reverts (NoKernel).

configHashOf

function configHashOf(StrategyConfig calldata c) external pure returns (bytes32)

A configuration’s hash, keccak256(abi.encode(c)): what fixes every member’s address.

Parameters

NameTypeDescription
cStrategyConfigThe strategy’s configuration (StrategyConfig).

memberAddress

function memberAddress(
    address owner,
    bytes32 configHash,
    uint256 index
) public view returns (address)

Where member index of the configuration configHash owned by owner lives, on every chain.

Parameters

NameTypeDescription
owneraddressThe owner.
configHashbytes32The configuration’s hash.
indexuint256The member’s place in the kind.

lineOf

function lineOf(
    bytes32 kind,
    uint256 index
) public pure returns (bytes32)

Member index’s line on a kind, keccak256(abi.encode(kind, index)): where its releases are listed.

Parameters

NameTypeDescription
kindbytes32The kind’s registry entry id.
indexuint256The member’s place in the kind.

Constants

Values compiled in, or set once when the contract is deployed (immutable).

address public immutable REGISTRY;
NameDescription
REGISTRYThe registry the builder reads, fixed in its bytes: the same address on every chain.

Events

MemberCreated event

event MemberCreated(
    address indexed member,
    address indexed owner,
    bytes32 indexed configHash,
    uint8 index,
    bytes32 release
);

A member of a strategy was created.

Emitted by: create, createRemote

Fields

NameTypeDescription
memberaddress · indexedIts address.
owneraddress · indexedIts owner.
configHashbytes32 · indexedThe configuration’s hash.
indexuint8Its place in the kind.
releasebytes32The release it starts on.

Errors

A call that fails reverts with one of these, so a block explorer or a simulation shows which rule refused it.

ErrorWhenRaised by
WrongChain()create called off the hub’s chain, or createRemote on the hub’s chain or for a member that does not live on this chain.create, createRemote
BadConfig()The configuration names another builder, a kind of fewer than 2 members or more than 5, a parameter or release count other than the kind’s, a first member that is not the hub, or a zero owner.create, createRemote
NotListed()The kind or the profile is not listed in its category, or is retired (create only); or a member’s named release is not an open VERSION entry of its line.create, createRemote
NotNewest()A member’s named release is numbered 0, or (create) is not its line’s newest.create, createRemote
BadSignature()The Create signature is not the sender’s: its ECDSA signature for a kind with a member off the hub’s chain, its ECDSA or ERC-1271 signature for a kind on one chain.create
BadRun()The creation’s run is not run 1 of this strategy naming every leg in the kind’s order at owner generation 0, or its deadline has passed.create
AlreadyCreated()A member already exists at its address.create, createRemote
DeployFailed()The member’s proxy did not land at its address.create, createRemote
BadKernel()A named kernel release’s kernel has no code, is an EIP-7702 delegation, or doesn’t hold the listed code.create, createRemote
NumberMismatch()A named kernel release’s listed number is not the number its code answers.create, createRemote
NoKernel()No member is being created: there is no kernel to answer.proxyImplementation

Types

StrategyConfig struct

A strategy’s configuration, as the owner sends it, whose hash fixes every member’s address: the builder that creates it, the owner’s salt (so one owner may create several strategies alike), the kind’s registry entry id, each member’s release (one VERSION entry id per kind member, on that member’s chain), the profile’s registry entry id, and one parameter block per kind member, abi-encoded.

struct StrategyConfig {
    address builder;
    bytes32 salt;
    bytes32 kind;
    bytes32[] releases;
    bytes32[] kernels;
    bytes32 profile;
    bytes[] params;
}

Permit struct

A USDC permit (EIP-2612) for the builder, signed by the owner: its deadline (zero for none) and its signature (v, r, s).

struct Permit {
    uint256 deadline;
    uint8 v;
    bytes32 r;
    bytes32 s;
}

On this page