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

Merge dev to main #81

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ ARB_MAINNET_RPC=

ARB_MAINNET_DEPLOYER_PK=0x
ARB_MAINNET_ADMIN_PK=0x

DEFAULT_KEY_PUBLIC_ADDRESS=0x
7 changes: 6 additions & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ concurrency:
group: ${{github.workflow}}-${{github.ref}}
cancel-in-progress: true

env:
FOUNDRY_PROFILE: ci
ARB_SEPOLIA_RPC: ${{ secrets.ARB_SEPOLIA_RPC }}
ARB_MAINNET_RPC: ${{ secrets.ARB_MAINNET_RPC }}

jobs:
build:
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
Open Dollar Relayer
</h1>

[![codecov](https://codecov.io/gh/open-dollar/od-relayer/graph/badge.svg?token=FB1JMPI0GX)](https://codecov.io/gh/open-dollar/od-relayer)

This repository contains the smart contracts for the relayers used in Open Dollar.

# Resources
Expand Down
120 changes: 92 additions & 28 deletions broadcast/DeployRelayers.s.sol/42161/run-latest.json

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
codecov:
require_ci_to_pass: yes

coverage:
status:
project:
default:
target: auto
threshold: 95
base: auto
precision: 2
round: down
range: "95...100"

parsers:
gcov:
branch_detection:
conditional: yes
loop: yes
method: no
macro: no

comment:
layout: "reach, diff, flags, files"
behavior: default
require_changes: false
require_base: no
require_head: yes

ignore:
- "test"
- "script"
- "src/libraries/"
- "src/contracts/for-test/"
160 changes: 160 additions & 0 deletions deployments/mainnet/deploy-factories-4-21-2024.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ number_underscore = 'thousands'
wrap_comments = false

[profile.default]
evm_version = "cancun"
auto_detect_solc = true
src = "src"
out = "out"
libs = ["lib"]

[rpc_endpoints]
mainnet = "${ARB_MAINNET_RPC}"
sepolia = "${ARB_SEPOLIA_RPC}"
sepolia = "${ARB_SEPOLIA_RPC}"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"url": "https://github.com/open-dollar/od-relayer"
},
"license": "MIT",
"author": "Keyp",
"author": "OpenFi Foundation",
"contributors": [
"pi0neerpat (https://github.com/pi0neerpat)",
"daopunk (https://github.com/daopunk)",
Expand Down
2 changes: 2 additions & 0 deletions script/Common.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ import {IAuthorizable} from '@interfaces/utils/IAuthorizable.sol';
import {CamelotRelayerFactory} from '@contracts/factories/CamelotRelayerFactory.sol';
import {ChainlinkRelayerFactory} from '@contracts/factories/ChainlinkRelayerFactory.sol';
import {DenominatedOracleFactory} from '@contracts/factories/DenominatedOracleFactory.sol';
import {IDelayedOracleFactory} from '@interfaces/factories/IDelayedOracleFactory.sol';

abstract contract CommonMainnet is Script {
ChainlinkRelayerFactory public chainlinkRelayerFactory = ChainlinkRelayerFactory(MAINNET_CHAINLINK_RELAYER_FACTORY);
CamelotRelayerFactory public camelotRelayerFactory = CamelotRelayerFactory(MAINNET_CAMELOT_RELAYER_FACTORY);
DenominatedOracleFactory public denominatedOracleFactory =
DenominatedOracleFactory(MAINNET_DENOMINATED_ORACLE_FACTORY);
IDelayedOracleFactory public delayedOracleFactory = IDelayedOracleFactory(MAINNET_DELAYED_ORACLE_FACTORY);
}

abstract contract CommonSepolia is Script {
Expand Down
169 changes: 169 additions & 0 deletions script/DeployOracle.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.7.6;

import '@script/Registry.s.sol';
import {Script} from 'forge-std/Script.sol';
import {CommonMainnet} from '@script/Common.s.sol';
import 'forge-std/console2.sol';

import {IBaseOracle} from '@interfaces/oracles/IBaseOracle.sol';

// BROADCAST
// source .env && forge script DeployEthUsdRelayer --with-gas-price 2000000000 -vvvvv --rpc-url $ARB_MAINNET_RPC --broadcast --verify --etherscan-api-key $ARB_ETHERSCAN_API_KEY --account defaultKey --sender $DEFAULT_KEY_PUBLIC_ADDRESS

// SIMULATE
// source .env && forge script DeployEthUsdRelayer --with-gas-price 2000000000 -vvvvv --rpc-url $ARB_MAINNET_RPC --sender $DEFAULT_KEY_PUBLIC_ADDRESS

contract DeployEthUsdRelayer is Script, CommonMainnet {
function run() public {
vm.startBroadcast();

chainlinkRelayerFactory.deployChainlinkRelayerWithL2Validity(
MAINNET_CHAINLINK_ETH_USD_FEED,
MAINNET_CHAINLINK_SEQUENCER_FEED,
1 days,
MAINNET_CHAINLINK_L2VALIDITY_GRACE_PERIOD
);

vm.stopBroadcast();
}
}

// BROADCAST
// source .env && forge script DeployLinkGrtEthOracles --with-gas-price 2000000000 -vvvvv --rpc-url $ARB_MAINNET_RPC --broadcast --verify --etherscan-api-key $ARB_ETHERSCAN_API_KEY --account defaultKey --sender $DEFAULT_KEY_PUBLIC_ADDRESS

// SIMULATE
// source .env && forge script DeployLinkGrtEthOracles --with-gas-price 2000000000 -vvvvv --rpc-url $ARB_MAINNET_RPC --sender $DEFAULT_KEY_PUBLIC_ADDRESS

contract DeployLinkGrtEthOracles is Script, CommonMainnet {
IBaseOracle public _linkUSDRelayer;
IBaseOracle public _grtUSDRelayer;
IBaseOracle public _ethDelayedOracle;

function run() public {
vm.startBroadcast();

_linkUSDRelayer = chainlinkRelayerFactory.deployChainlinkRelayerWithL2Validity(
MAINNET_CHAINLINK_LINK_USD_FEED,
MAINNET_CHAINLINK_SEQUENCER_FEED,
1 hours,
MAINNET_CHAINLINK_L2VALIDITY_GRACE_PERIOD
);
_grtUSDRelayer = chainlinkRelayerFactory.deployChainlinkRelayerWithL2Validity(
MAINNET_CHAINLINK_GRT_USD_FEED,
MAINNET_CHAINLINK_SEQUENCER_FEED,
1 days,
MAINNET_CHAINLINK_L2VALIDITY_GRACE_PERIOD
);

IBaseOracle linkOracle = delayedOracleFactory.deployDelayedOracle(_linkUSDRelayer, MAINNET_ORACLE_DELAY);
IBaseOracle grtOracle = delayedOracleFactory.deployDelayedOracle(_grtUSDRelayer, MAINNET_ORACLE_DELAY);
IBaseOracle ethOracle = delayedOracleFactory.deployDelayedOracle(
IBaseOracle(MAINNET_CHAINLINK_L2VALIDITY_ETH_USD_RELAYER), MAINNET_ORACLE_DELAY
);

linkOracle.getResultWithValidity();
grtOracle.getResultWithValidity();
ethOracle.getResultWithValidity();

vm.stopBroadcast();
}
}

// BROADCAST
// source .env && forge script DeployWstethRethL2ValidityOracles --with-gas-price 2000000000 -vvvvv --rpc-url $ARB_MAINNET_RPC --broadcast --verify --etherscan-api-key $ARB_ETHERSCAN_API_KEY --account defaultKey --sender $DEFAULT_KEY_PUBLIC_ADDRESS

// SIMULATE
// source .env && forge script DeployWstethRethL2ValidityOracles --with-gas-price 2000000000 -vvvvv --rpc-url $ARB_MAINNET_RPC --sender $DEFAULT_KEY_PUBLIC_ADDRESS

contract DeployWstethRethL2ValidityOracles is Script, CommonMainnet {
IBaseOracle public _wstethETHRelayer;
IBaseOracle public _rethETHRelayer;

function run() public {
vm.startBroadcast();

_wstethETHRelayer = chainlinkRelayerFactory.deployChainlinkRelayerWithL2Validity(
MAINNET_CHAINLINK_WSTETH_ETH_FEED,
MAINNET_CHAINLINK_SEQUENCER_FEED,
1 days,
MAINNET_CHAINLINK_L2VALIDITY_GRACE_PERIOD
);
_rethETHRelayer = chainlinkRelayerFactory.deployChainlinkRelayerWithL2Validity(
MAINNET_CHAINLINK_RETH_ETH_FEED,
MAINNET_CHAINLINK_SEQUENCER_FEED,
1 days,
MAINNET_CHAINLINK_L2VALIDITY_GRACE_PERIOD
);

IBaseOracle _wstethUsdOracle = denominatedOracleFactory.deployDenominatedOracle(
_wstethETHRelayer, IBaseOracle(MAINNET_CHAINLINK_L2VALIDITY_ETH_USD_RELAYER), false
);

IBaseOracle _rethUsdOracle = denominatedOracleFactory.deployDenominatedOracle(
_rethETHRelayer, IBaseOracle(MAINNET_CHAINLINK_L2VALIDITY_ETH_USD_RELAYER), false
);

IBaseOracle wstethOracle = delayedOracleFactory.deployDelayedOracle(_wstethUsdOracle, MAINNET_ORACLE_DELAY);
IBaseOracle rethOracle = delayedOracleFactory.deployDelayedOracle(_rethUsdOracle, MAINNET_ORACLE_DELAY);

wstethOracle.getResultWithValidity();
rethOracle.getResultWithValidity();

vm.stopBroadcast();
}
}

// BROADCAST
// source .env && forge script DeployCamelotOdUsdOracle --with-gas-price 2000000000 -vvvvv --rpc-url $ARB_MAINNET_RPC --broadcast --verify --etherscan-api-key $ARB_ETHERSCAN_API_KEY --sender $DEFAULT_KEY_PUBLIC_ADDRESS --account defaultKey

// SIMULATE
// source .env && forge script DeployCamelotOdUsdOracle --with-gas-price 2000000000 -vvvvv --rpc-url $ARB_MAINNET_RPC --sender $DEFAULT_KEY_PUBLIC_ADDRESS

contract DeployCamelotOdUsdOracle is Script, CommonMainnet {
IBaseOracle public _odEthCamelotRelayer;
IBaseOracle public _odUsdOracle;

function run() public {
vm.startBroadcast();

_odEthCamelotRelayer = camelotRelayerFactory.deployAlgebraRelayer(
MAINNET_ALGEBRA_FACTORY, MAINNET_SYSTEM_COIN, MAINNET_WETH, uint32(MAINNET_CAMELOT_QUOTE_PERIOD)
);

_odUsdOracle = denominatedOracleFactory.deployDenominatedOracle(
_odEthCamelotRelayer, IBaseOracle(MAINNET_CHAINLINK_L2VALIDITY_ETH_USD_RELAYER), false
);

_odUsdOracle.getResultWithValidity();

vm.stopBroadcast();
}
}

// BROADCAST
// source .env && forge script DeployCamelotOdgUsdOracle --with-gas-price 2000000000 -vvvvv --rpc-url $ARB_MAINNET_RPC --broadcast --verify --etherscan-api-key $ARB_ETHERSCAN_API_KEY --sender $DEFAULT_KEY_PUBLIC_ADDRESS --account defaultKey

// SIMULATE
// source .env && forge script DeployCamelotOdgUsdOracle --with-gas-price 2000000000 -vvvvv --rpc-url $ARB_MAINNET_RPC --sender $DEFAULT_KEY_PUBLIC_ADDRESS

contract DeployCamelotOdgUsdOracle is Script, CommonMainnet {
IBaseOracle public _odgEthCamelotRelayer;
IBaseOracle public _odgUsdOracle;

function run() public {
vm.startBroadcast();

_odgEthCamelotRelayer = camelotRelayerFactory.deployAlgebraRelayer(
MAINNET_ALGEBRA_FACTORY, MAINNET_PROTOCOL_TOKEN, MAINNET_WETH, uint32(MAINNET_CAMELOT_QUOTE_PERIOD)
);

_odgUsdOracle = denominatedOracleFactory.deployDenominatedOracle(
_odgEthCamelotRelayer, IBaseOracle(MAINNET_CHAINLINK_L2VALIDITY_ETH_USD_RELAYER), false
);

_odgUsdOracle.getResultWithValidity();

vm.stopBroadcast();
}
}
82 changes: 50 additions & 32 deletions script/Registry.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,44 +60,62 @@ address constant SEPOLIA_ALGEBRA_FARM_CENTER = 0x04e4A5A4E4D2A5a0fb48ECde0bbD555

// -- Mainnet --

////////// CONSTANTS //////////
address constant MAINNET_DEPLOYER = 0xF78dA2A37049627636546E0cFAaB2aD664950917;
uint256 constant MAINNET_ORACLE_DELAY = 1 hours;
uint256 constant MAINNET_CHAINLINK_L2VALIDITY_GRACE_PERIOD = 1 hours;
uint256 constant MAINNET_CAMELOT_QUOTE_PERIOD = 1 hours;
address constant MAINNET_PROTOCOL_TOKEN = 0x000D636bD52BFc1B3a699165Ef5aa340BEA8939c;
address constant MAINNET_SYSTEM_COIN = 0x221A0f68770658C15B525d0F89F5da2baAB5f321;
address constant MAINNET_WETH = 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1;
address constant ETH = 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1;
address constant ARB = 0x912CE59144191C1204E64559FE8253a0e49E6548;
address constant ETH_ARB_POOL = 0xe51635ae8136aBAc44906A8f230C2D235E9c195F;

////////// FACTORIES //////////
address constant MAINNET_CAMELOT_RELAYER_FACTORY = 0x36645830479170265A154Acb726780fdaE41A28F;
address constant MAINNET_CHAINLINK_RELAYER_FACTORY = 0x06C32500489C28Bd57c551afd8311Fef20bFaBB5;
address constant MAINNET_DENOMINATED_ORACLE_FACTORY = 0xBF760b23d2ef3615cec549F22b95a34DB0F8f5CD;
address constant MAINNET_ALGEBRA_FACTORY = 0x1a3c9B1d2F0529D97f2afC5136Cc23e58f1FD35B;

// Pre-deployment relayer factories
address constant MAINNET_CAMELOT_RELAYER_FACTORY = 0xC235041D2ea652261f816e4e8F56bD02AD623E11;
address constant MAINNET_CHAINLINK_RELAYER_FACTORY = 0x62f4A8565BDca2bB2b7975D4d5B48F61DA8846f5;
address constant MAINNET_DENOMINATED_ORACLE_FACTORY = 0xb6010972669953F6212B4AD969753c6e22ed5131;

// Relayers
address constant MAINNET_CAMELOT_ODG_WETH_RELAYER = 0xF7Ec9ad3192d4ec1E54d52B3E492B5B66AB02889;

address constant MAINNET_CHAINLINK_ETH_USD_RELAYER = 0x1d2eA5253A3dc201d2275885621c095C6e656e29;
address constant MAINNET_CHAINLINK_RETH_ETH_RELAYER = 0x007E6300C8D98F5B34dFe040248A596482d82B3f;
address constant MAINNET_DELAYED_ORACLE_FACTORY = 0x9Dd63fA54dEfd8820BCAb3e3cC39aeEc1aE88098;

////////// RELAYERS //////////
// Camelot
address constant MAINNET_CAMELOT_ODG_WETH_RELAYER = 0x10ef7FEcf888Bc4B1F64757B77317946fFBc5873;
address constant MAINNET_CAMELOT_OD_WETH_RELAYER = 0x43261bFF12F8D26Ae3E3ef6924Eca6FA5c32f4b6;
// Chainlink
address constant MAINNET_CHAINLINK_ETH_USD_RELAYER = 0x3e6C1621f674da311E57646007fBfAd857084383;
address constant MAINNET_CHAINLINK_L2VALIDITY_ETH_USD_RELAYER = 0x4617Feb8B72167c3b8253a1327CddE44e54670Ce;
address constant MAINNET_CHAINLINK_RETH_ETH_RELAYER = 0x2b98972Ee61e8928F9dFa6504301296f0e7645Ca;
address constant MAINNET_CHAINLINK_WSTETH_ETH_RELAYER = 0x48D3B7605B8dc3Ae231Bd59e40513C9e9Ac6D33a;

address constant MAINNET_DENOMINATED_ODG_USD_ORACLE = 0xE90E52eb676bc00DD85FAE83D2FAC22062F7f470;
address constant MAINNET_DENOMINATED_RETH_USD_ORACLE = 0xCa3AD386d14d851A5fF5f08De2Bd2de88db2d5A0;
address constant MAINNET_DENOMINATED_WSTETH_USD_ORACLE = 0xCeE84f86d76bADa12262138b860D772812334DD6;

// Oracles params
uint256 constant MAINNET_ORACLE_INTERVAL = 1 hours;

// Chainlink price feeds to USD
address constant MAINNET_CHAINLINK_ARB_USD_FEED = 0xb2A824043730FE05F3DA2efaFa1CBbe83fa548D6;
address constant MAINNET_CHAINLINK_L2VALIDITY_RETH_ETH_RELAYER = 0x77A15A5b9b7e1DE3EDf797662ADf1e74AF88f8Bd;
address constant MAINNET_CHAINLINK_L2VALIDITY_WSTETH_ETH_RELAYER = 0x4dF7048DC8696832A146ac4Ba8f7a791f258916c;
address constant MAINNET_CHAINLINK_ARB_USD_RELAYER = 0x2635f731BB6981E72F92A781578952450759F762;
// Denominated
address constant MAINNET_DENOMINATED_ODG_USD_ORACLE = 0x734B085f68Ee612A7e51927e7B070CddE948C510;
address constant MAINNET_DENOMINATED_OD_USD_ORACLE = 0x53BA82f08639F5D0ac7b61471A6CAc0B2FAb7372;
address constant MAINNET_DENOMINATED_RETH_USD_ORACLE = 0xE0ac4511A617cBee55ECb62667B08DB6864B9d8e;
address constant MAINNET_DENOMINATED_WSTETH_USD_ORACLE = 0x8746664d1E0F0e61275EF3B52A8a3b3dFC11CcAb;
address constant MAINNET_DENOMINATED_L2VALIDITY_RETH_USD_ORACLE = 0x35843B3B7838eA15D0cAf2E61AD52C72b95b3Ca7;
address constant MAINNET_DENOMINATED_L2VALIDITY_WSTETH_USD_ORACLE = 0x9C9D6E07b58d1808d29d9dB118dd32b97DBba26A;
// Delayed
address constant MAINNET_DELAYED_RETH_USD_ORACLE = 0x0859c0B3EF150fAb129E43B74a63da13F5d2Dd35;
address constant MAINNET_DELAYED_WSTETH_USD_ORACLE = 0xa8dEa011Ed90C53BA4601868Ccc9a36A6F442499;
address constant MAINNET_DELAYED_L2VALIDITY_RETH_USD_ORACLE = 0xCe962D4Ac9d70776e17C031192Fac64540F1a5D9;
address constant MAINNET_DELAYED_L2VALIDITY_WSTETH_USD_ORACLE = 0xb0ecE3904d69CCC4B7A7EcFEedf96298448B2CB9;
address constant MAINNET_DELAYED_ARB_USD_ORACLE = 0xa4e0410E7eb9a02aa9C0505F629d01890c816A77;
address constant MAINNET_DELAYED_ETH_USD_ORACLE = 0x562CCE2F4dc383862dC6A926AF10DeFf5fCd172F;

////////// CHAINLINK //////////
// Price feeds to USD
address constant MAINNET_CHAINLINK_ETH_USD_FEED = 0x639Fe6ab55C921f74e7fac1ee960C0B6293ba612;

// Chainlink price feeds to ETH
address constant MAINNET_CHAINLINK_ARB_USD_FEED = 0xb2A824043730FE05F3DA2efaFa1CBbe83fa548D6;
// Price feeds to ETH
address constant MAINNET_CHAINLINK_RETH_ETH_FEED = 0xD6aB2298946840262FcC278fF31516D39fF611eF;
address constant MAINNET_CHAINLINK_WSTETH_ETH_FEED = 0xb523AE262D20A936BC152e6023996e46FDC2A95D;
address constant MAINNET_CHAINLINK_CBETH_ETH_FEED = 0xa668682974E3f121185a3cD94f00322beC674275;
address constant MAINNET_CHAINLINK_RETH_ETH_FEED = 0xD6aB2298946840262FcC278fF31516D39fF611eF;

// Chainlink sequencer feed for Arbitrum One
address constant MAINNET_CHAINLINK_LINK_USD_FEED = 0x86E53CF1B870786351Da77A57575e79CB55812CB;
address constant MAINNET_CHAINLINK_GRT_USD_FEED = 0x0F38D86FceF4955B705F35c9e41d1A16e0637c73;
address constant MAINNET_CHAINLINK_EZETH_ETH_FEED = 0x11E1836bFF2ce9d6A5bec9cA79dc998210f3886d;
// Sequencer for Arbitrum One
address constant MAINNET_CHAINLINK_SEQUENCER_FEED = 0xFdB631F5EE196F0ed6FAa767959853A9F217697D;

address constant ETH = 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1;
address constant ARB = 0x912CE59144191C1204E64559FE8253a0e49E6548;
address constant ETH_ARB_POOL = 0xe51635ae8136aBAc44906A8f230C2D235E9c195F;

address constant MAINNET_DEPLOYER = 0xF78dA2A37049627636546E0cFAaB2aD664950917;
6 changes: 3 additions & 3 deletions script/predeployment/DeployFactories.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ contract DeployFactoriesMain is Script {
_chainlinkRelayerFactory = new ChainlinkRelayerFactory();
_denominatedOracleFactory = new DenominatedOracleFactory();

_camelotRelayerFactory.addAuthorization(MAINNET_DEPLOYER);
_chainlinkRelayerFactory.addAuthorization(MAINNET_DEPLOYER);
_denominatedOracleFactory.addAuthorization(MAINNET_DEPLOYER);
//_camelotRelayerFactory.addAuthorization(MAINNET_DEPLOYER);
//_chainlinkRelayerFactory.addAuthorization(MAINNET_DEPLOYER);
//_denominatedOracleFactory.addAuthorization(MAINNET_DEPLOYER);
vm.stopBroadcast();
}
}
Expand Down
Loading
Loading