Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #198 from 1inch/spot-price-aggregator/oracle-deplo…
Browse files Browse the repository at this point in the history
…yment-guide

[SC-1084] Oracle Deployment Guide
  • Loading branch information
zZoMROT authored Feb 27, 2024
2 parents 920a5da + d542d1d commit fc6501b
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 2 deletions.
6 changes: 4 additions & 2 deletions docs/spot-price-aggregator/introduction.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
sidebar_position: 1
---


# Spot Price Aggregator
# Introduction

[![Build Status](https://github.com/1inch/spot-price-aggregator/actions/workflows/test.yml/badge.svg)](https://github.com/1inch/spot-price-aggregator/actions)
[![Coverage Status](https://codecov.io/gh/1inch/spot-price-aggregator/branch/master/graph/badge.svg?token=6V7609YJ1Q)](https://codecov.io/gh/1inch/spot-price-aggregator)
Expand Down
64 changes: 64 additions & 0 deletions docs/spot-price-aggregator/oracle-deployment-guide.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
sidebar_position: 3
---

# Oracle Deployment Guide

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.

### Step 1: Surveying DEX Liquidity

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.

### Step 2: Selection of DEXes

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.

### Step 3: Network Configuration

3. **Configure the Network Settings:**
- 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.
- Update the [Hardhat settings file](https://github.com/1inch/spot-price-aggregator/blob/master/hardhat.config.js) to configure the network.
- Utilize the `Networks` class from [solidity-utils](https://github.com/1inch/solidity-utils/blob/master/hardhat-setup/networks.ts) for network registration.
- Example configuration snippet:
```javascript
...
const { Networks } = require('@1inch/solidity-utils/hardhat-setup');
const net = new Networks(true, 'mainnet', true);
net.register(your_network_name, networkId, process.env.YOURNETWORK_RPC_URL, process.env.YOURNETWORK_PRIVATE_KEY, etherscan_network_name, process.env.YOURNETWORK_ETHERSCAN_KEY);
const networks = net.networks;
const etherscan = net.etherscan;
...
```

### Step 4: Environment Variables

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:

- `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.

- `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.

- `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.

### Step 5: Deploying Oracles

5. **Deploy Oracles:**
- Use the deploy script located at `deploy/commands/simple-deploy.js`.
- Configure the `PARAMS` object for each protocol you wish to deploy an oracle for. The parameters include:
- **contractName**: Name of the contract from the `contracts/oracles/` directory.
- **args**: Arguments required by the contract (See contract's constructor).
- **deploymentName**: A name for your deployment, which will be used to create a file in the `deployments/` directory.
- 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.
- Example command for deployment: `yarn && yarn deploy <your_network_name>`.

### Step 6: Deploying Wrappers

6. **Deploy Wrappers:**
- Follow similar steps as step 5 to deploy necessary wrappers. You can find it in the `contracts/wrappers/` directory.

### Step 7: Deploying OffchainOracle

7. **Deploy OffchainOracle:**
- 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.

0 comments on commit fc6501b

Please sign in to comment.