# Pool Factory API

### MarginlyFactory

Deploys Marginly and manages ownership and control over pool

#### marginlyPoolImplementation

```solidity
address marginlyPoolImplementation
```

#### uniswapFactory

```solidity
address uniswapFactory
```

Address of uniswap factory

#### swapRouter

```solidity
address swapRouter
```

Address of uniswap swap router

#### feeHolder

```solidity
address feeHolder
```

Swap fee holder

#### WETH9

```solidity
address WETH9
```

Address of wrapped ETH

#### techPositionOwner

```solidity
address techPositionOwner
```

Technical position address

#### getPool

```solidity
mapping(address => mapping(address => mapping(uint24 => address))) getPool
```

Returns the pool address for a given pair of tokens and a fee, or address 0 if it does not exist

*quoteToken and baseToken may be passed in either token0/token1 or token1/token0 order*

#### constructor

```solidity
constructor(address _marginlyPoolImplementation, address _uniswapFactory, address _swapRouter, address _feeHolder, address _WETH9, address _techPositionOwner) public
```

#### createPool

```solidity
function createPool(address quoteToken, address baseToken, uint24 uniswapFee, struct MarginlyParams params) external returns (address pool)
```

Creates a pool for the two given tokens and fee

*tokenA and tokenB may be passed in either order: token0/token1 or token1/token0. tickSpacing is retrieved from the fee. The call will revert if the pool already exists, the fee is invalid, or the token arguments are invalid.*

**Parameters**

| Name       | Type                  | Description                                     |
| ---------- | --------------------- | ----------------------------------------------- |
| quoteToken | address               | One of the two tokens in the desired pool       |
| baseToken  | address               | The other of the two tokens in the desired pool |
| uniswapFee | uint24                | Fee for uniswap pool                            |
| params     | struct MarginlyParams | pool parameters                                 |

**Return Values**

| Name | Type    | Description                           |
| ---- | ------- | ------------------------------------- |
| pool | address | The address of the newly created pool |

#### changeSwapRouter

```solidity
function changeSwapRouter(address newSwapRouter) external
```

Changes swap router address used by Marginly pools

**Parameters**

| Name          | Type    | Description                |
| ------------- | ------- | -------------------------- |
| newSwapRouter | address | address of new swap router |

#### renounceOwnership

```solidity
function renounceOwnership() public
```

Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner.

NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.marginly.com/protocol-architecture/pools/pool-factory-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
