> For the complete documentation index, see [llms.txt](https://docs.efficientdex.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.efficientdex.com/run-a-pool/configure-a-pool.md).

# Configure a pool

How a pool operator creates an Efficient pool, chooses its pair and genesis mode, activates it and sets its limits and execution buffer.

**A pool operator creates an Efficient pool with one factory call.** That call deploys, configures and seeds the pool in a single transaction. Much of what it sets is fixed for the pool's life. [Operate a pool](/run-a-pool/operate-a-pool.md) covers the calls a live pool needs.

## Creating a pool

### Before the factory call

1. Deploy an authority contract, such as the standard `EverlongCore`. It names the pool operator as owner, an optional guardian and keeper, and the fee receiver.
2. Name a guardian other than the pool operator, or none. The pool refuses to schedule a lending market from the guardian's address.
3. Choose the pair, the price feed and any genesis lending markets. The pair is the pool asset and the first loan asset. The loan asset is the other token in the pair, which the pool can borrow from a lending market. In an Efficient pool that trades BTC against USDC, it's USDC. Asset pairs and Genesis modes below cover these choices.
4. Deploy a deposit allowlist bound to the authority contract, or pass none. With none, any address can receive shares from a deposit.
5. Read the pool's future address from `predictPool(creator, salt, p)`. Deploy the pool's hooks bound to that address (see [Build a hook](/run-a-pool/build-a-hook.md)). Then approve the seed to the factory. Changing any setting in `p` changes the address, except the seed, safety gap and oracle band. `predictPool` itself validates nothing.

### The factory call

```solidity
function createPool(
    PoolParams calldata p,
    IFLAMM.HookSet calldata hooks,
    bytes32 salt,
    IFLAMM.VenueInit[] calldata venues
) external returns (address pool);
```

The struct `p` holds the seed, as `seedPoolAssets` and `seedReceiver`. It also holds most other starting settings, listed under Setting risk limits and dials. `hooks` fills the three required roles: the invariant, fee and recentring hooks. It holds zero for any optional hook left out.

`venues` lists any genesis lending markets. These pass the admission checks in [Just-in-time financing](/how-pools-work/just-in-time-financing.md) but skip the governance delay.

In one transaction, `createPool` deploys the pool and registers it with the financing router. It installs the pool's hooks and admits the first loan asset. Then it adds any genesis lending markets and applies the default protocol fee. Last, it takes the seed and locks 1,000 base units of shares at a dead address.

| Revert                                           | Cause                                                                                                                                                                                                                                                                                                                                                                    |
| ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `InvalidConfig` from the factory                 | A zero seed, no seed receiver, or an authority contract without code                                                                                                                                                                                                                                                                                                     |
| `CreateFailed()`                                 | A pair the feed refuses, an asset over 18 decimals, a `RiskInit` value out of bounds, or an address in use                                                                                                                                                                                                                                                               |
| `InvalidConfig` from the financing router        | A zero LTV pin, a pin plus safety gap of 1 or more, an oracle band over 20%, a first loan asset equal to the pool asset, or a genesis market with borrowing on and a liquidation LTV under the pin plus the gap                                                                                                                                                          |
| `MarketUnknown`, `VenueMismatch` or `OracleBand` | A genesis market that isn't the pair's Morpho Blue market with the reviewed rate model, or has its oracle outside the band, or has borrowing on in a pool with no price band                                                                                                                                                                                             |
| `HookInvalid`                                    | Required roles not filled as [Build a hook](/run-a-pool/build-a-hook.md) requires. A hook without code, bound to another pool or on another interface version. An invariant or loan-to-loan swap hook not answering `boundPool()` with this pool and `hookInterfaceVersion()` with 3, or, with no price band, an invariant hook that doesn't declare `HOOK_CAP_UNPRICED` |
| `InvalidConfig` from the pool                    | A pool asset under six decimals, a pair under the price floors, or a feed that can't price the pair at admission                                                                                                                                                                                                                                                         |
| `BelowMinimumShares`                             | A seed minting 1,000 base units of shares or fewer                                                                                                                                                                                                                                                                                                                       |

### Asset pairs

**A pool with a price band admits a pair only if it passes two sets of checks.** The first set runs at deployment. The feed must list both assets, with no peg band on the pool asset. Neither asset can have over 18 decimals. Breaking either rule fails the deployment with `CreateFailed()`.

The second set is four admission checks, run after deployment. They use the price that [Price feeds and oracles](/how-pools-work/price-feeds-and-oracles.md) derives. A failed check reverts with `InvalidConfig` from the pool:

* The pool asset has at least six decimals.
* Each USD price is at least a million of its feed's steps.
* The pair's `price36` is at least 1e6. `price36` is loan-asset base units per pool-asset base unit, times 1e36.
* For the first loan asset, `price36` over 10 to the loan asset's decimals is also at least 1e6. That ratio is the hooks' N36 frame.

These price floors keep rounding under a millionth of the price. Pairs near parity, such as wstETH against WETH, pass them. The floors apply only at admission. So a live pool whose price later drifts under one keeps its net asset value and its exits.

**A pool born with a zero `swapPriceBandWad` has no price band.** So its feed needs to list only the loan asset. The price floors don't apply to it. Its pool asset still needs six decimals, and its `ltvMaxWad` can't exceed 1e9. Its invariant hook must declare `HOOK_CAP_UNPRICED`.

Such a pool starts with borrowing off. Borrowing stays off while the pool has no band. [Hooks](/how-pools-work/hooks.md) explains how a pool runs with no price band.

### Genesis modes

**A pool finances itself in one of three modes from its first block.** `venues` and the calls after `createPool` set the mode. The first Everlong vault starts in the borrowing mode, seeded with its pool asset alone.

| Mode              | How it's set                                                                                                                                    | What the pool does                                             |
| ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- |
| Borrowing         | A genesis lending market with borrowing on, plus supply and `FEATURE_SUPPLY_LENDING` to lend surplus                                            | Borrows when a sell needs more loan asset than it holds        |
| Supply only       | A genesis lending market with borrowing off and supply on, the loan asset's borrow switch off in `setLoanCaps`, and `FEATURE_SUPPLY_LENDING` on | Lends its surplus and never borrows                            |
| No lending market | An empty `venues` array, or every lending market retired with `retireVenue`                                                                     | Pays sells from loan asset on hand and reads no lending market |

A pool with no price band can't borrow. So it runs in one of the last two modes.

A pool that can't borrow needs an invariant hook that quotes no leverage, because a lever-up borrows its payout. For the Everlong hook, no leverage means an all-zero leverage row and `FEATURE_LEVERAGE` off.

**A pool can also open two-sided.** The pool operator calls `seedLeg(assets, to)` to add the first loan asset at net asset value. It works while `to` holds every share but the 1,000 locked at creation. A leg sized to the loan-asset side of the invariant hook's book lets a pool that can't borrow pay sells before its first buy.

With no price band, `seedLeg` mints no shares. So the loan asset adds value to the shares `to` already holds.

### Activating the pool

**A pool can be created paused, through `startPaused` in `RiskInit`.** Unpausing it is then the first step that adds risk. A pause stops sells and deposits but not buys. So the deployer also leaves buys out of `features`, to keep anyone from trading against the seed.

The first Everlong vault is created that way, at features 59, and its pool operator activates it in three calls:

1. `acceptOwnership()` on the authority contract, which the deployer hands over.
2. `setPaused(false)` on the pool.
3. `setFeatures(63)`, which switches buys on.

`features` is a bitmap of flows. It sums deposits 1, sells 2, buys 4, supply lending 8, maintenance 16, leverage 32 and loan-to-loan swaps 64. So 63 is every flow but loan-to-loan swaps.

The order changes if the Everlong hook's anchor has drifted more than one recentre step from the feed price. In that case, the pool operator:

1. Calls `setFeatures(17)`, for deposits and maintenance only.
2. Unpauses the pool.
3. Has the keeper call `recenter`.
4. Calls `setFeatures(63)`.

## Setting risk limits and dials

**Most of a pool's starting settings come from the factory call.** A few start at fixed defaults. Most can change later, each through one call. Each change applies at once, except a performance fee rise and a ceiling raise. Those two wait for the governance delay. A raise of the band ceiling waits at least 10 days.

| Setting                                                  | At creation                                                                                                                                                                                            | Later                                                                                                                               |
| -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------- |
| Pair, feed, authority contract, allowlist and share name | `poolAsset`, `loanAsset`, `priceFeed`, `core`, `allowlist`, `name`, `symbol`                                                                                                                           | Fixed. Roles and allowlist entries change in their own contracts                                                                    |
| LTV pin and credit setting                               | `ltvWad`, `phiWad`                                                                                                                                                                                     | `setDials`, by the keeper or the pool operator. It can only lower the LTV where no lending market has borrowing on or debt          |
| Credit limits                                            | `RiskInit`'s dial envelopes, move limits and credit room margin, under 10%, and `safetyGapWad`                                                                                                         | Fixed                                                                                                                               |
| Oracle band                                              | `venueOracleBandWad`, at most 20%, zero for off                                                                                                                                                        | `setOracleBand`                                                                                                                     |
| First loan asset's swap limits                           | `swapPriceBandWad` (at most 10%, or zero for no price band), `maxSwapNotionalLoan`, `reserveTargetLoan`                                                                                                | `setRiskLimits` or `setLoanConfig`, with the band under its ceiling. `setMarketBand` drops or attaches a band                       |
| Fee floor and cap                                        | `feeFloorWad` for the pool and the first loan asset, and `feeCapWad` (at most 100%)                                                                                                                    | `setFeeBounds`, with the cap under its ceiling, or `setLoanConfig` for a loan asset's floor                                         |
| Band and fee-cap ceilings                                | The starting `swapPriceBandWad` and `feeCapWad`, or a band ceiling that admits no band in a pool born without one                                                                                      | `setBandAndFeeCeilings`                                                                                                             |
| Performance fee                                          | `maxPerformanceFeeBp` (at most 5,000 bp), with the rate at zero                                                                                                                                        | `setPerformanceFeeBp`, under the fixed ceiling. A pool with no price band refuses a rise and charges no performance or protocol fee |
| Governance delay and loan-to-loan price age              | `governanceDelaySec`, at least one day, and `maxPriceAgeSec`                                                                                                                                           | Fixed                                                                                                                               |
| Switches and pause                                       | `features`, `startPaused`                                                                                                                                                                              | `setFeatures`, `setPaused`                                                                                                          |
| Genesis lending markets                                  | Each `venues` entry's switches, caps and rate ceiling                                                                                                                                                  | `setVenueFlags`, `setVenueCaps`                                                                                                     |
| Fixed defaults                                           | A drawn set of one. No loan-asset caps, with the borrow switch on (off in a pool with no price band). A supply batch of zero. The fund re-check on. A `mintProRata` cap of zero. No pool-asset reserve | `setRiskLimits`, `setLoanCaps`, `setMinSupplyBatch`, `setFundRecheck`, `setMintProRataCap`, `setPoolAssetReserve`                   |

A pool has no cap of its own on `depositProRata`, the entry sized in pool asset. In a pool with lending markets, the pool's debt and supply caps bound a deposit's legs. `FEATURE_DEPOSITS`, the allowlist or a pause can close deposits.

The share-sized entry, `mintProRata`, has its own cap on the share supply after the mint. Zero, the default, closes that entry. The largest `uint128` value leaves it uncapped.

The guardian can make several of these calls too, but only to tighten. See [Roles and governance](/run-a-pool/roles-and-governance.md). [Credit and collateral](/how-pools-work/credit-and-collateral.md) explains the dials. [Hooks](/how-pools-work/hooks.md) covers the price band, its ceiling, fee bounds and hook changes.

## The execution buffer settings

**A pool's execution buffer is what it keeps on hand of each asset.** It lets a trade pay out without a lending-market call. Each loan asset's reserve target and minimum supply batch set the loan-asset side. In a pool that borrows, the pool-asset side is the pool asset it holds but hasn't posted as collateral.

`setPoolAssetReserve` sets how far a buy refills the pool asset on hand. The rest stays posted as collateral. This rule needs a lending market that pays a return on collateral. Morpho Blue doesn't, so no pool can switch it on today. [Just-in-time financing](/how-pools-work/just-in-time-financing.md) covers both sides of the buffer in full.

The first Everlong vault ships its reserve target and supply batch at zero. So it keeps no loan-asset buffer and supplies every surplus.
