Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: v1.1.0 #7

Merged
merged 3 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
NODE_URI_ETHEREUM=
NODE_URI_OPTIMISM=
NODE_URI_POLYGON=
NODE_URI_GOERLI=
NODE_URI_OPTIMISTICGOERLI=
NODE_URI_MUMBAI=
NODE_URI_SEPOLIA=
NODE_URI_OPTIMISTICSEPOLIA=

# Account's private keys
ETHEREUM_1_PRIVATE_KEY=
Expand All @@ -13,10 +12,9 @@ TEST_1_PRIVATE_KEY=
# Etherscan (optional, only for verifying smart contracts)
ETHEREUM_ETHERSCAN_API_KEY=
OPTIMISTICETHEREUM_ETHERSCAN_API_KEY=
GOERLI_ETHERSCAN_API_KEY=
OPTIMISTICGOERLI_ETHERSCAN_API_KEY=
POLYGONMUMBAI_ETHERSCAN_API_KEY=
POLYGON_ETHERSCAN_API_KEY=
SEPOLIA_ETHERSCAN_API_KEY=
OPTIMISTICSEPOLIA_ETHERSCAN_API_KEY=

# Mocha (10 minutes)
MOCHA_TIMEOUT=600000
Expand Down
28 changes: 0 additions & 28 deletions .github/workflows/sync.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ jobs:
run: yarn test:e2e
env:
NODE_URI_ETHEREUM: ${{ secrets.NODE_URI_MAINNET }}
NODE_URI_GOERLI: https://eth-goerli.alchemyapi.io/v2/${{ secrets.ALCHEMYKEY }}
NODE_URI_SEPOLIA: https://eth-sepolia.g.alchemy.com/v2/${{ secrets.ALCHEMYKEY }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ artifacts
typechained
deployments/hardhat
deployments/localhost
deployments/sepoliaDummy
deployments/sepolia
deployments/optimisticSepolia
deployments/**/solcInputs

# Config files
.env
Expand Down
84 changes: 57 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
- [Setup](#setup)
- [Address Registry](#address-registry)
- [Testnet](#testnet)
- [Goerli (sender and _receiver_)](#goerli-sender-and-receiver)
- [OP Goerli (_receiver_)](#op-goerli-receiver)
- [Mumbai (manual sender)](#mumbai-manual-sender)
- [Sepolia (sender and _receiver_)](#sepolia-sender-and-receiver)
- [OP Sepolia (_receiver_)](#op-sepolia-receiver)
- [Mumbai (manual sender)](#sepolia-manual-sender)
- [Whitelisted pipelines](#whitelisted-pipelines)

## Scope
Expand Down Expand Up @@ -169,7 +169,7 @@ NOTE: A more gas-efficient array-filling strategy can be built by making more ex

## Setup

Clone the repo in your preferred way, and fill the `.env` file using the `.env.example` as a reference. The environment is yet set to work with testnets, using Goerli to OP Goerli bridge as default.
Clone the repo in your preferred way, and fill the `.env` file using the `.env.example` as a reference. The environment is yet set to work with testnets, using Sepolia to OP Sepolia bridge as default.

For a dummy setup (without bridging) run:

Expand All @@ -195,45 +195,75 @@ yarn deploy:work
```

For 1 tag manual-deployment and bridging
`yarn deploy --network mumbai --tags manual-send-test-observation`
`yarn deploy --network sepolia --tags manual-send-test-observation`

In `/utils/constants.ts`, one can find the configuration of the strategies chosen by chain. The default for Goerli is set to refresh each 1/2 day, using periods of 1hr, and comparing a 2hr twap with 500 ticks (+-5%) threshold.
In `/utils/constants.ts`, one can find the configuration of the strategies chosen by chain. The default for Sepolia is set to refresh each 1/2 day, using periods of 1hr, and comparing a 2hr twap with 500 ticks (+-5%) threshold.

## Production deployment

Make sure to have the correct addresses for `tokenA` and `tokenB` in `utils/constants.ts` as well as the desired `periodLength`, `strategyCooldown`, `twapPeriod`, and `twapThreshold`. Also check the correct fee, as if an inexistent UniswapV3 pool is referenced, the script will eventually deploy it.

Setup the `receiver` network for the origin chain (e.g. `ethereum`, receiver `polygon`) and select the desired script to run using the origin chain as script selected network (even if the deployment occurs in the sidechain), with the exception of `verify` scripts. Each script will execute the required subsequent ones, so it is not necessary to run them all.

This script will deploy (the OracleFactory if necessary and) the DataReceiver, in the receiver chain of `ethereum` (that it might be `optimism` or `polygon`). This is to enable the off-chain coordination.

```bash
yarn deploy --network ethereum --tags data-receiver
```

Scripts:

- `data-sender`: deploys DataFeed (mainnet)
- `data-receiver`: deploys OracleFactory and DataReceiver (sidechain)
- `connext-setup`: runs both `data-sender` and `data-receiver` (if not yet deployed) plus deploys Connext SenderAdapter and ReceiverAdapter
- `manual-fetch-observation`: runs `data-receiver` and attempts to fetch a new observation with arbitrary timestamps
- `fetch-observation`: runs `data-receiver` plus deploys DataFeedStrategy and attempts to programatically fetch a new observation
- `bridge-observation`: runs up to `connext-setup` and attempts to bridge a recently fetched observation
- `setup-keeper`: runs up to `connext-setup` and deploys StrategyJob
- `work-job`: (runs up to `setup-keeper` and) attempts to work StrategyJob (requires registration in Keep3r contract)

## Address Registry

#### Testnet
#### Mainnet

##### Goerli (sender and _receiver_)
##### Optimism (_receiver_)

| Contract | Address |
| ------------------------- | -------------------------------------------- |
| DataFeed | `0x8Fb68E83831c7e8622e10C154CC0d24856440809` |
| DataFeedStrategy | `0x606e25c67B8d6550075C8085083c763769Cfe2BE` |
| StrategyJob | `0x606e25c67B8d6550075C8085083c763769Cfe2BE` |
| Connext SenderAdapter | `0xF73E6BC8ca4Fec5e9773C4f22E8EBEEEd12733d6` |
| _Connext ReceiverAdapter_ | `0x05a6CEF3f938E8E9b3112CB44e8B9771638989Ed` |
| _DataReceiver_ | `0xa09683377E5cE0bB7eEa90D2b64e3644f7eA1B8a` |
| _OracleFactory_ | `0x0594Dc74043b93Bdb371f01187704C98D45bd4E6` |
| _Connext ReceiverAdapter_ | `0xe5BE7f12B94D185f892c4BBe6F88ABE65CE1A8af` |
| _DataReceiver_ | `0x4E0CeF6426eb70b5708845825A5375688808891d` |
| _OracleFactory_ | `0x0BcD059c1546359b45f2606Ed6E08e1F5ef4f4Bf` |

##### OP Goerli (_receiver_)
##### Polygon (_receiver_)

| Contract | Address |
| ------------------------- | -------------------------------------------- |
| _Connext ReceiverAdapter_ | `0x4D81A5C9F7706377df368D1716460da03faEcBcb` |
| _DataReceiver_ | `0x768c227320165A71A4001fE23A0C38CD6B5585c0` |
| _OracleFactory_ | `0xB8aD440Ad7A3298C73258b1Fc202A081Db9107cb` |
| _Connext ReceiverAdapter_ | `0x4839750090571A0fCcBaa3a8Fffe3DE22b4B7D51` |
| _DataReceiver_ | `0xe5BE7f12B94D185f892c4BBe6F88ABE65CE1A8af` |
| _OracleFactory_ | `0x69ceAA797274fd85F3b3a1f5b29857BFD9B9b259` |

#### Testnet

##### Mumbai (manual sender)
##### Sepolia (sender)

| Contract | Address |
| --------------------- | -------------------------------------------- |
| DataFeed | `0x1c9Bc091f070A10E23B2a90eA543AD38AA3De1EE` |
| Connext SenderAdapter | `0x4C8589e7D1d91e454F5f30C3e1bb3e197B5Bf368` |
| DataFeed | `0xcDddb7c04000e492E2e6CbD924b595CdaB9DEFa9` |
| DataFeedStrategy | `0x8379506385432f1e02cE516f5A5F52d15E250c88` |
| StrategyJob | `0xa77E459Eba5F1D05Cd22C8a28fB6b2725dfd4D21` |
| Connext SenderAdapter | `0x54B79C4B3E5BA80275B33B5bCaaeC762bf04E558` |

##### OP Sepolia (_receiver_)

| Contract | Address |
| ------------------------- | -------------------------------------------- |
| _Connext ReceiverAdapter_ | `0x4839750090571A0fCcBaa3a8Fffe3DE22b4B7D51` |
| _DataReceiver_ | `0x4B11b6BEF9480d62b471a9a91a52C893143Bad19` |
| _OracleFactory_ | `0xa32f6603F9466eF0190CAc36759E41B40653471A` |

##### Whitelisted pipelines:

| Chain - Pool | Chain - OracleSidechain |
| ----------------------------------------------------- | -------------------------------------------------------- |
| Goerli - `0x317ceCd3eB02158f97DF0B67B788edCda4E066e5` | OP Goerli - `0x4ECFF2c532d47D7be3D957E4a332AB134cad1fd9` |
| Mumbai - `0xd69f1635dc28a11E05841AE25Fd1572FD0EF1eF4` | Goerli - `0x050BBA5E4abde750Ea5610D8412cD46171C665e7` |
| Goerli - `0x317ceCd3eB02158f97DF0B67B788edCda4E066e5` | Goerli - `0xED7f635EE962537b4DB13a1e1c3922EC65366fE2` |
| Chain - Pool | Chain - OracleSidechain |
| ------------------------------------------------------ | ----------------------- |
| Mainnet - `0xTODO` | OP - `0xTBD` |
| Sepolia - `0xd0EAFA86eC9C2f3f8f12798974222C645dc8DBF0` | OP Sepolia - `0xTBD` |
4 changes: 2 additions & 2 deletions deploy/0-deployments/003_data_feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { HardhatRuntimeEnvironment } from 'hardhat/types';
import { dataFeedSettings } from '../../utils/constants';

const deployFunction: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployer } = await hre.getNamedAccounts();
const { deployer, uniV3Factory } = await hre.getNamedAccounts();

const chainId = Number(await hre.getChainId());
const minLastOracleDelta = dataFeedSettings[chainId];

const CONSTRUCTOR_ARGS = [deployer, deployer, minLastOracleDelta];
const CONSTRUCTOR_ARGS = [deployer, deployer, uniV3Factory, minLastOracleDelta];

await hre.deployments.deploy('DataFeed', {
contract: 'solidity/contracts/DataFeed.sol:DataFeed',
Expand Down
4 changes: 2 additions & 2 deletions deploy/0-deployments/004_data_feed_strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { HardhatRuntimeEnvironment } from 'hardhat/types';
import { strategySettings } from '../../utils/constants';

const deployFunction: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployer } = await hre.getNamedAccounts();
const { deployer, uniV3Factory } = await hre.getNamedAccounts();

const chainId = Number(await hre.getChainId());
const deploymentSettings = strategySettings[chainId];

const dataFeed = await hre.deployments.get('DataFeed');
const CONSTRUCTOR_ARGS = [deployer, dataFeed.address, deploymentSettings];
const CONSTRUCTOR_ARGS = [deployer, dataFeed.address, uniV3Factory, deploymentSettings];

await hre.deployments.deploy('DataFeedStrategy', {
contract: 'solidity/contracts/DataFeedStrategy.sol:DataFeedStrategy',
Expand Down
7 changes: 4 additions & 3 deletions deploy/1-setup/102_setup_pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { HardhatRuntimeEnvironment } from 'hardhat/types';
import { DeployFunction } from 'hardhat-deploy/types';
import { calculateSalt } from '../../test/utils/misc';
import { ZERO_ADDRESS } from '../../test/utils/constants';
import { TEST_FEE, UNI_V3_FACTORY } from '../../utils/constants';
import { TEST_FEE } from '../../utils/constants';
import { getReceiverChainId } from '../../utils/deploy';

const deployFunction: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployer, tokenA, tokenB } = await hre.getNamedAccounts();
const { deployer, tokenA, tokenB, uniV3Factory } = await hre.getNamedAccounts();
const DESTINATION_CHAIN_ID = await getReceiverChainId(hre);

const txSettings = {
Expand All @@ -18,7 +18,7 @@ const deployFunction: DeployFunction = async function (hre: HardhatRuntimeEnviro

await hre.deployments.save('UniswapV3Factory', {
abi: IUniswapV3Factory.abi,
address: UNI_V3_FACTORY,
address: uniV3Factory,
});

const POOL_ADDRESS = await hre.deployments.read('UniswapV3Factory', 'getPool', tokenA, tokenB, TEST_FEE);
Expand All @@ -40,5 +40,6 @@ const deployFunction: DeployFunction = async function (hre: HardhatRuntimeEnviro
}
};

deployFunction.dependencies = ['create-pool'];
deployFunction.tags = ['pool-whitelisting'];
export default deployFunction;
7 changes: 4 additions & 3 deletions deploy/1-setup/121_setup_dummy_pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { HardhatRuntimeEnvironment } from 'hardhat/types';
import { DeployFunction } from 'hardhat-deploy/types';
import { calculateSalt } from '../../test/utils/misc';
import { ZERO_ADDRESS } from '../../test/utils/constants';
import { TEST_FEE, UNI_V3_FACTORY } from '../../utils/constants';
import { TEST_FEE } from '../../utils/constants';

const deployFunction: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployer, tokenA, tokenB } = await hre.getNamedAccounts();
const { deployer, tokenA, tokenB, uniV3Factory } = await hre.getNamedAccounts();
const DESTINATION_CHAIN_ID = await hre.getChainId();

const txSettings = {
Expand All @@ -17,7 +17,7 @@ const deployFunction: DeployFunction = async function (hre: HardhatRuntimeEnviro

await hre.deployments.save('UniswapV3Factory', {
abi: IUniswapV3Factory.abi,
address: UNI_V3_FACTORY,
address: uniV3Factory,
});

const POOL_ADDRESS = await hre.deployments.read('UniswapV3Factory', 'getPool', tokenA, tokenB, TEST_FEE);
Expand All @@ -39,5 +39,6 @@ const deployFunction: DeployFunction = async function (hre: HardhatRuntimeEnviro
}
};

deployFunction.dependencies = ['create-pool'];
deployFunction.tags = ['test-pool-whitelisting'];
export default deployFunction;
6 changes: 3 additions & 3 deletions deploy/2-token-actions/202_save_pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import IUniswapV3Pool from '../../artifacts/@uniswap/v3-core/contracts/interface
import { HardhatRuntimeEnvironment } from 'hardhat/types';
import { DeployFunction } from 'hardhat-deploy/types';
import { ZERO_ADDRESS } from '../../test/utils/constants';
import { TEST_FEE, UNI_V3_FACTORY } from '../../utils/constants';
import { TEST_FEE } from '../../utils/constants';

const deployFunction: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { tokenA, tokenB } = await hre.getNamedAccounts();
const { tokenA, tokenB, uniV3Factory } = await hre.getNamedAccounts();

await hre.deployments.save('UniswapV3Factory', {
abi: IUniswapV3Factory.abi,
address: UNI_V3_FACTORY,
address: uniV3Factory,
});

const POOL_ADDRESS = await hre.deployments.read('UniswapV3Factory', 'getPool', tokenA, tokenB, TEST_FEE);
Expand Down
13 changes: 3 additions & 10 deletions deploy/2-token-actions/212_deploy_pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import IUniswapV3Factory from '../../artifacts/@uniswap/v3-core/contracts/interf
import IUniswapV3Pool from '../../artifacts/@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol/IUniswapV3Pool.json';
import { HardhatRuntimeEnvironment } from 'hardhat/types';
import { DeployFunction } from 'hardhat-deploy/types';
import { TEST_FEE, UNI_V3_FACTORY } from '../../utils/constants';
import { TEST_FEE } from '../../utils/constants';

const deployFunction: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployer } = await hre.getNamedAccounts();
const { deployer, uniV3Factory } = await hre.getNamedAccounts();
const addressZero = '0x0000000000000000000000000000000000000000';

const txSettings = {
Expand All @@ -15,7 +15,7 @@ const deployFunction: DeployFunction = async function (hre: HardhatRuntimeEnviro

await hre.deployments.save('UniswapV3Factory', {
abi: IUniswapV3Factory.abi,
address: UNI_V3_FACTORY,
address: uniV3Factory,
});

/* DEPLOY POOL */
Expand All @@ -36,13 +36,6 @@ const deployFunction: DeployFunction = async function (hre: HardhatRuntimeEnviro
address: UNI_V3_POOL_ADDRESS,
});

console.log('deployed', {
tokenA: tokenA.address,
tokenB: tokenB.address,
fee: TEST_FEE,
pool: UNI_V3_POOL_ADDRESS,
});

/* INITIALIZE POOL */

let poolSlot0 = await hre.deployments.read('UniswapV3Pool', 'slot0');
Expand Down
1 change: 0 additions & 1 deletion deploy/3-bridge-actions/312_dummy_bridge_observation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ const deployFunction: DeployFunction = async function (hre: HardhatRuntimeEnviro
abi: OracleSidechain.abi,
address: DUMMY_ORACLE_ADDRESS,
});
await verifyContractByAddress(hre, DUMMY_ORACLE_ADDRESS);
await hre.deployments.execute('DummyOracleSidechain', txSettings, 'initializePoolInfo', tokenA, tokenB, TEST_FEE);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const deployFunction: DeployFunction = async function (hre: HardhatRuntimeEnviro

const dataFeedContract = await hre.ethers.getContractAt('DataFeed', dataFeed.address);

const SECONDS_AGOS = [10000, 5000, 0];
const SECONDS_AGOS = [3600, 1800, 0];
const FETCH_OBSERVATION_ARGS = [salt, SECONDS_AGOS];
await hre.deployments.execute('DataFeed', txSettings, 'fetchObservations(bytes32,uint32[])', ...FETCH_OBSERVATION_ARGS);

Expand Down
3 changes: 3 additions & 0 deletions deploy/4-verify/413_verify_dummy_adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import { verifyContract } from 'utils/deploy';
const deployFunction: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const dummyAdapter = await hre.deployments.get('DummyAdapterForTest');
await verifyContract(hre, dummyAdapter, 'solidity/for-test/DummyAdapterForTest.sol/DummyAdapterForTest');

const dummyOracleSidechain = await hre.deployments.get('DummyOracleSidechain');
await verifyContract(hre, dummyOracleSidechain, 'solidity/for-test/DummyOracleSidechain.sol/DummyOracleSidechain');
};

deployFunction.tags = ['verify-dummy-adapter'];
Expand Down
Loading
Loading