# Noah Factory

## Contract info

**Contract name:**  Noah Factory

View [NoahFactory.sol on Github.](https://github.com/NoaharkEVM/noah-contract/blob/main/projects/exchange-protocol/contracts/NoahFactory.sol)

**EOS EVM  Network**\
Contract addres&#x73;**:** 0x75782A57c6522B8B17FCc01Ff11759f4535b2752\
View the [Noah Swap:Factory contract on evm](https://explorer.evm.eosnetwork.com/address/0x75782A57c6522B8B17FCc01Ff11759f4535b2752)

## Read functions

### getPair

`function getPair(address tokenA, address tokenB) external view returns (address pair);`

Address for `tokenA` and address for `tokenB` return address of pair contract (where one exists).

`tokenA` and `tokenB` order is interchangeable.

Returns `0x0000000000000000000000000000000000000000` as address where no pair exists.

### allPairs

`function allPairs(uint) external view returns (address pair);`

Returns the address of the `n`th pair (`0`-indexed) created through the Factory contract.

Returns `0x0000000000000000000000000000000000000000` where pair has not yet been created.

Begins at `0` for first created pair.

### allPairsLength

`function allPairsLength() external view returns (uint);`

Displays the current number of pairs created through the Factory contract as an integer.

### feeTo

`function feeTo() external view returns (address);`

The address to where non-LP-holder fees are sent.

### getFeeRate \#

`function` getFeeRate`(`address pair`) external view returns (uint);`

The right to set the handling fee for each pair, the default is 0.3%.

## Write functions

### createPair

function createPair(address tokenA, address tokenB) external returns (address pair);

Creates a pair for `tokenA` and `tokenB` where a pair doesn't already exist.

`tokenA` and `tokenB` order is interchangeable.

Emits `PairCreated` (see Events).

### setFeeTo

function setFeeTo(address account) external returns ();

Sets address for `feeTo`.

### setFeeRate

function setFeeRate(address pair,`uint`) external returns ();

Set the handling fee for each pair.

### toggleState

function toggleState() external returns ();

Set the contract switch and update the status once.

## Events

### PairCreated

`event PairCreated(address indexed token0, address indexed token1, address pair, uint);`

Emitted whenever a `createPair` creates a new pair.

`token0` will appear before `token1` in sort order.

The final `uint` log value will be `1` for the first pair created, `2` for the second.

### SetFeeRate

`event` SetFeeRate`(address indexed pair, uint);`

The log that is synchronized after each transaction fee is set.

## Interface

`import './interfaces/INoahFactory.sol';`

<pre><code><strong>// pragma solidity >=0.5.0;
</strong>interface INoahFactory { 
    event PairCreated(address indexed token0, address indexed token1, address pair, uint256 pid); 
    
    event SetFeeRate(address indexed pair, uint256 feeRate);
    
<strong>    // Returns uint
</strong>    // Pending  - 0
    // Active  - 1
    enum State {Pending, Active}
    
    function state() external view returns (State);
    
    function feeTo() external view returns (address);
    
    function admin() external view returns (address);
    
    function getPair(address tokenA, address tokenB) external view returns (address pair);
    
    function getFeeRate(address pair) external view returns (uint256 feeRate);
    
    function allPairs(uint256) external view returns (address pair);
    
    function allPairsLength() external view returns (uint256);
    
    function createPair(address tokenA, address tokenB) external returns (address pair);
    
    function setFeeTo(address) external;
    
    function setAdmin(address) external;
    
    function setFeeRate(address pair, uint256 _feeRate) external;
    
    function toggleState() external;
    
    function INIT_CODE_PAIR_HASH() external view returns (bytes32);
}
</code></pre>


---

# 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://noah-finance.gitbook.io/noah/fan-ti/zhi-neng-he-yue/noah-swap/noah-factory.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.
