|
| 1 | +--- |
| 2 | +sidebar_position: 3 |
| 3 | +--- |
| 4 | + |
| 5 | +# Oracle Deployment Guide |
| 6 | + |
| 7 | +This section provides a comprehensive guide on deploying an oracle, including the nuances of script parameters and additional setup steps. Follow these steps to ensure accurate and reliable oracle deployment for price data retrieval. |
| 8 | + |
| 9 | +### Step 1: Surveying DEX Liquidity |
| 10 | + |
| 11 | +1. **Identify DEXes with Sufficient Liquidity:** Begin by surveying the network for Decentralized Exchanges (DEXes) that offer sufficient liquidity. This ensures the oracle can retrieve reliable and accurate price data. |
| 12 | + |
| 13 | +### Step 2: Selection of DEXes |
| 14 | + |
| 15 | +2. **Select Supported DEXes:** Choose DEXes that are supported by `SpotPriceAggregator` or are forks of supported protocols. Supported DEXes can be found in the `contracts/oracles/` directory of the project. |
| 16 | + |
| 17 | +### Step 3: Network Configuration |
| 18 | + |
| 19 | +3. **Configure the Network Settings:** |
| 20 | + - Skip this step if your network is supported. This can be checked by observing whether the network is mentioned (registered or not) during a test run, visible in the console output. This verification can be done also by reviewing the `registerAll` method in the [`Networks` class](https://github.com/1inch/solidity-utils/blob/master/hardhat-setup/networks.ts#L108-L128). If your network is listed there, it's considered supported, and no further action is required for registration in this step. |
| 21 | + - Update the [Hardhat settings file](https://github.com/1inch/spot-price-aggregator/blob/master/hardhat.config.js) to configure the network. |
| 22 | + - Utilize the `Networks` class from [solidity-utils](https://github.com/1inch/solidity-utils/blob/master/hardhat-setup/networks.ts) for network registration. |
| 23 | + - Example configuration snippet: |
| 24 | + ```javascript |
| 25 | + ... |
| 26 | + const { Networks } = require('@1inch/solidity-utils/hardhat-setup'); |
| 27 | + const net = new Networks(true, 'mainnet', true); |
| 28 | + net.register(your_network_name, networkId, process.env.YOURNETWORK_RPC_URL, process.env.YOURNETWORK_PRIVATE_KEY, etherscan_network_name, process.env.YOURNETWORK_ETHERSCAN_KEY); |
| 29 | + const networks = net.networks; |
| 30 | + const etherscan = net.etherscan; |
| 31 | + ... |
| 32 | + ``` |
| 33 | + |
| 34 | +### Step 4: Environment Variables |
| 35 | + |
| 36 | +4. **Set Environment Variables:** Define necessary environment variables in the `.env` file located at the project root. Include variables such as `YOURNETWORK_RPC_URL`, `YOURNETWORK_PRIVATE_KEY`, and `YOURNETWORK_ETHERSCAN_KEY` with appropriate values: |
| 37 | + |
| 38 | + - `YOURNETWORK_RPC_URL`: The RPC URL for accessing your network's node. This URL can support the HTTP header 'auth-key'. To use this header, append the header value to the URL using the `|` symbol. For example: `http://localhost:8545|HeaderValue`. This format allows you to authenticate requests to your node. |
| 39 | + |
| 40 | + - `YOURNETWORK_PRIVATE_KEY`: Your account's private key, which should be entered without the `0x` prefix. This key is used for deploying contracts and executing transactions on the network. |
| 41 | + |
| 42 | + - `YOURNETWORK_ETHERSCAN_KEY`: The API key for an Etherscan-like blockchain explorer that supports your network. This key is necessary for verifying and publishing your contract's source code. Ensure you register for an API key with a compatible explorer service for your network. |
| 43 | + |
| 44 | +### Step 5: Deploying Oracles |
| 45 | + |
| 46 | +5. **Deploy Oracles:** |
| 47 | + - Use the deploy script located at `deploy/commands/simple-deploy.js`. |
| 48 | + - Configure the `PARAMS` object for each protocol you wish to deploy an oracle for. The parameters include: |
| 49 | + - **contractName**: Name of the contract from the `contracts/oracles/` directory. |
| 50 | + - **args**: Arguments required by the contract (See contract's constructor). |
| 51 | + - **deploymentName**: A name for your deployment, which will be used to create a file in the `deployments/` directory. |
| 52 | + - Ensure the `skip` [flag](https://github.com/1inch/spot-price-aggregator/blob/master/deploy/commands/simple-deploy.js#L25) is set to `false` to proceed with deployment. |
| 53 | + - Example command for deployment: `yarn && yarn deploy <your_network_name>`. |
| 54 | + |
| 55 | +### Step 6: Deploying Wrappers |
| 56 | + |
| 57 | +6. **Deploy Wrappers:** |
| 58 | + - Follow similar steps as step 5 to deploy necessary wrappers. You can find it in the `contracts/wrappers/` directory. |
| 59 | + |
| 60 | +### Step 7: Deploying OffchainOracle |
| 61 | + |
| 62 | +7. **Deploy OffchainOracle:** |
| 63 | + - Follow similar steps as step 5 to deploy the `OffchainOracle`. Make sure to include the deployed oracles (from step 5), wrappers (from step 6) and specifying the tokens you wish to use as connectors for price discovery. After `OffchainOracle` is deployed, it will be possible to edit these lists of oracles, wrappers and connectors. |
| 64 | + |
0 commit comments