# Create the builder pool

## Pool creation

In the protocol, any user can create a builder pool by calling the `createBuilderPool` function. During creation, the user must specify a unique project name that will be used to generate the pool’s identifier using `keccak256`. Additionally, the creator must provide the builder’s address (the admin of the pool), who will be responsible for managing it. The builder must also define key parameters: the start time of the pool (`poolStart`), the withdrawal lock period after deposit (`withdrawLockPeriodAfterDeposit`), the reward claim unlock time (`claimLockEnd`), and the minimum allowed deposit amount (`minimalDeposit`). All of these parameters are validated by the contract before being accepted.

## Pool params

Each field in the `BuilderPool` struct plays a crucial role in defining the behavior of the pool. The `name` is the project label, used both for user identification and as the input for generating the unique pool ID.&#x20;

The `admin` field is the builder’s address, responsible for performing reward claims and pool management.&#x20;

The `poolStart` defines the timestamp from which users can begin depositing; any deposits made before this time will be rejected.&#x20;

`withdrawLockPeriodAfterDeposit` specifies the minimum time (in seconds) that must elapse after a user deposits before they are allowed to withdraw their tokens. This helps maintain deposit stability.

The `claimLockEnd` field defines when the `admin` can start claiming rewards and apply lock multiplier for all stakes until this timestamp.

&#x20;The `minimalDeposit` parameter ensures that any deposit (or remaining balance after a partial withdrawal) must meet or exceed a minimum threshold unless the user is fully withdrawing.

## Pool edit

Editing an existing pool is allowed only until the pool’s start time (`poolStart`). Only the builder (admin) who created the pool can perform edits. The `editBuilderPool` function accepts the same struct as the creation call, allowing modification of lock periods and start time. However, the new `poolStart` must not be earlier than the previously set one — this prevents time-based manipulation or rollback of the pool’s launch.

## Pool ID

The pool receives a unique `builderPoolId` derived from the project name using the following Solidity expression:

```solidity
bytes32 builderPoolId = keccak256(abi.encodePacked(builderPool.name));
```

This ID is then used in all pool-related operations including deposits, withdrawals, reward claiming, and internal data storage for builder configuration, user stakes, and reward accounting.
