> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mystockline.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# EquityOracleFactory

> EquityOracleFactory deploys EquityOracle instances with CREATE2.

EquityOracleFactory deploys EquityOracle instances with CREATE2. The salt is the hash of the full config, so the same inputs always produce the same address, and a repeat call returns the existing oracle. It keeps a mapping from stock token to oracle and emits the complete config so indexers can reconstruct every parameter.

`EquityOracleFactory` lets you:

* Deploy an oracle for a stock token from a config struct
* Predict the oracle address before deploying
* Look up the oracle registered for a stock token

Addresses per network. Every address is also on [Addresses](/resources/addresses).

| Network                 | Address                                                                                                                                       |
| ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| Robinhood Chain testnet | [0x57C2b3dd7C7d2e92B905B976caa66fbdCD6C50DD](https://explorer.testnet.chain.robinhood.com/address/0x57C2b3dd7C7d2e92B905B976caa66fbdCD6C50DD) |

The source code is [`src/oracles/EquityOracleFactory.sol`](https://github.com/stockline-xyz/contracts/blob/main/src/oracles/EquityOracleFactory.sol) on GitHub. The ABI is [`/abis/EquityOracleFactory.json`](/abis/EquityOracleFactory.json).

## Write methods

### create

```solidity theme={"system"}
function create(EquityOracleConfig calldata cfg) external returns (address oracle)
```

Deploys an EquityOracle for `cfg` or returns the existing one at the predicted address. Permissionless. Reverts with AlreadyListed if the stock token already has an oracle at a different address (a different config). The constructor may also revert with EquityOracle's config errors.

<Note>
  Anyone can deploy. The oracle only matters once governance points a book at it through RiskRegistry.
</Note>

**Input parameters**

| Name | Type                 | Description                                                                                                                                                                                                                                                                                    |
| ---- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| cfg  | `EquityOracleConfig` | EquityOracleConfig struct: `stockToken`, `loanToken`, `stockFeed`, `loanFeed`, `sequencerFeed` (may be zero), `calendar`, `liveStaleness`, `loanStaleness`, `maxDarkDuration` (seconds), `darkHaircutBps`, `caBoundaryWindow`, `sequencerGrace`, `darkStartOffset`, `darkEndOffset` (seconds). |

**Return values**

| Type      | Description                 |
| --------- | --------------------------- |
| `address` | oracle: The oracle address. |

## Read methods

### predict

```solidity theme={"system"}
function predict(EquityOracleConfig calldata cfg) public view returns (address)
```

Computes the CREATE2 address `create` would use for `cfg` without deploying.

**Input parameters**

| Name | Type                 | Description                                            |
| ---- | -------------------- | ------------------------------------------------------ |
| cfg  | `EquityOracleConfig` | The same EquityOracleConfig struct passed to `create`. |

**Return values**

| Type      | Description               |
| --------- | ------------------------- |
| `address` | Predicted oracle address. |

## Events

### OracleCreated

```solidity theme={"system"}
event OracleCreated(
    address indexed oracle,
    address indexed stockToken,
    EquityOracleConfig config
)
```

Fires on every successful `create`, with the oracle, the stock token, and the full config.

## Errors

### AlreadyListed

```solidity theme={"system"}
error AlreadyListed(address stockToken)
```

The stock token already has an oracle deployed from a different config.
