> For the complete documentation index, see [llms.txt](https://midaswap.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://midaswap.gitbook.io/docs/contracts/midasfactory721.md).

# MidasFactory721

### MidasFactory721

Contract used to deploy and register new MidasPairs. Enables setting fee parameters, protocol fees and Midas Pair implementation.

#### constructor

```Solidity
constructor(address _royaltyEngine)
```

**Parameters**

| **Name**        | **Type** | **Description**                                |
| --------------- | -------- | ---------------------------------------------- |
| \_royaltyEngine | address  | The smart contract which provides royalty data |

#### OwnerChanged

```Solidity
event OwnerChanged(address indexed oldOwner, address indexed newOwner);
```

#### PairImplementationSet

```Solidity
event PairImplementationSet(address indexed oldPair, address indexed newPair);
```

#### LptImplementationSet

```Solidity
event LptImplementationSet(address indexed oldLPT, address indexed newLPT);
```

#### PairCreated

```Solidity
event PairCreated(address indexed tokenX, address indexed tokenY, address indexed pair, address lpToken);
```

#### feeRecipient

```Solidity
function feeRecipient() external view
```

View function to get the recipient address which receives the protocol fee.

**Return Values**

| **Name**       | **Type** | **Description**                       |
| -------------- | -------- | ------------------------------------- |
| \_feeRecipient | address  | The recipient address of protocol fee |

#### createERC721Pair

```Solidity
function createERC721Pair(address _tokenX, address _tokenY) external override noDelegateCall
```

Function to create a new Midas Pair for \_token0 and \_token1.

**Parameters**

| **Name** | **Type** | **Description**                 |
| -------- | -------- | ------------------------------- |
| \_tokenX | address  | The address of the first token  |
| \_tokenY | address  | The address of the second token |

**Return Values**

| **Name** | **Type** | **Description**                            |
| -------- | -------- | ------------------------------------------ |
| lpToken  | address  | The address of LP token                    |
| pair     | address  | The address of the newly created MidasPair |

#### setOwner

```Solidity
function setOwner(address _owner) external
```

Function to set up a new owner of the factory.

**Parameters**

| **Name** | **Type** | **Description**              |
| -------- | -------- | ---------------------------- |
| \_owner  | address  | The address of the new owner |

#### setRoyaltyInfo

```Solidity
function setRoyaltyInfo(address _nftAddress, address _pair) public 
```

Function to update royalty info for the specific MidasPair.

**Parameters**

| **Name**     | **Type** | **Description**                               |
| ------------ | -------- | --------------------------------------------- |
| \_nftAddress | address  | The address of the NFT asset in the MidasPair |
| \_pair       | address  | The address of the MidasPair                  |

#### setRoyaltyEngine

```Solidity
function setRoyaltyEngine(address _newRoyaltyEngine) external 
```

Function to update royalty engine contract address.

**Parameters**

| **Name**           | **Type** | **Description**                |
| ------------------ | -------- | ------------------------------ |
| \_newRoyaltyEngine | address  | The new Royalty Engine address |

#### setRoyaltyInfo

```Solidity
 function setRoyaltyInfo(address _tokenX, address _tokenY, bool isZero) external
```

Function to set a new royalty rate for all the following MidasPair.

**Parameters**

| **Name** | **Type** | **Description**                 |
| -------- | -------- | ------------------------------- |
| address  | \_tokenX | The address of the NFT          |
| address  | \_tokenY | The address of the FT           |
| isZero   | bool     | Initialize royalty rate for NFT |

#### setPairImplementation

```Solidity
function setPairImplementation(address _newPairImplementation) external 
```

Function to set a new implementation of MidasPair to be cloned.

**Parameters**

| **Name**                | **Type** | **Description**                       |
| ----------------------- | -------- | ------------------------------------- |
| \_newPairImplementation | address  | The new template address of MidasPair |

#### setLptImplementation

```Solidity
function setLptImplementation(address _newLptImplementation) external 
```

Function to set a new implementation of LPToken to be cloned.

**Parameters**

| **Name**               | **Type** | **Description**                     |
| ---------------------- | -------- | ----------------------------------- |
| \_newLptImplementation | address  | The new template address of LPToken |

#### flashLoan

```Solidity
function flashLoan(address _token0, address _token1, IMidasFlashLoanCallback receiver, uint256[] calldata _tokenIds, bytes calldata data) external
```

Function to execute flash loans towards the specific MidasPair.

**Parameters**

| **Name**   | **Type**                | **Description**                                         |
| ---------- | ----------------------- | ------------------------------------------------------- |
| \_tokenX   | address                 | The address of NFT                                      |
| \_tokenY   | address                 | The address of FT                                       |
| receiver   | IMidasFlashLoanCallback | The implementation of receiver                          |
| \_tokenIds | uint256\[] calldata     | The list of NFT tokenIds to be borrowed                 |
| data       | bytes calldata          | The data to be transferred along with function revoking |
