# Deployment

Initial deployment of the MetaStreet v2 Pool contracts is proxied to allow for upgrades and bug fixes. However, deployment will ultimately migrate to immutable Pools, which are already supported by the codebase.

Proxied contracts are currently owned by the MetaStreet Labs multisig, but will ultimately be transferred to protocol governance.

#### Pool Factory

The [`PoolFactory`](https://github.com/metastreet-labs/metastreet-contracts-v2/blob/master/contracts/PoolFactory.sol) contract is deployed as an ERC1967 proxy, with a permissioned `upgradeToAndCall()` API to facilitate upgrades, and permissioned `addPoolImplementation()` and `removePoolImplementation()` to add and remove supported Pool implementations.

#### Pool Deployment

Proxied pools are deployed as an ERC1967 `BeaconProxy` with the [`PoolFactory`](https://github.com/metastreet-labs/metastreet-contracts-v2/blob/master/contracts/PoolFactory.sol) `createProxied()` function, which accepts a Pool implementation beacon and initialization parameters.

Immutable pools are deployed as an ERC1167 minimal clone proxy with the [`PoolFactory`](https://github.com/metastreet-labs/metastreet-contracts-v2/blob/master/contracts/PoolFactory.sol) `create()` function, which accepts a Pool implementation contract and initialization parameters.

Pools can be created permissionlessly. The admin for all Pools is the [`PoolFactory`](https://github.com/metastreet-labs/metastreet-contracts-v2/blob/master/contracts/PoolFactory.sol), which currently is only used to set the admin fee rate and withdraw admin fees. See the [Admin Fees](https://docs.metastreet.xyz/technical-overview/protocol-design/admin-fees) section for more information on admin fees.

As the Pool contract stabilizes, deployment will ultimately switch from `createProxied()` to `create()` and use versioned Pool implementations for newly created Pools.

#### Collateral Liquidator Deployment

The [`EnglishAuctionCollateralLiquidator`](https://github.com/metastreet-labs/metastreet-contracts-v2/tree/master/contracts/liquidators) contract is deployed as an ERC1967 `BeaconProxy`. This contract can also be deployed immutably.

#### Collateral Wrapper Deployment

The [`BundleCollateralWrapper`](https://github.com/metastreet-labs/metastreet-contracts-v2/blob/master/contracts/wrappers/BundleCollateralWrapper.sol) and [`ERC1155CollateralWrapper`](https://github.com/metastreet-labs/metastreet-contracts-v2/blob/master/contracts/wrappers/ERC1155CollateralWrapper.sol) contracts are deployed as ERC1967 `TransparentUpgradeableProxy`. These contracts can also be deployed immutably.
