Skip to content

Commit

Permalink
Merge branch 'dev' into add-pendle-relayers
Browse files Browse the repository at this point in the history
  • Loading branch information
MrDeadCe11 authored Jul 13, 2024
2 parents 22dca66 + 9d37566 commit a1a956e
Show file tree
Hide file tree
Showing 7 changed files with 212 additions and 30 deletions.
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
74 changes: 74 additions & 0 deletions script/DeployOracle.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// 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 {CamelotRelayerFactory} from '@contracts/factories/CamelotRelayerFactory.sol';
import {ChainlinkRelayerFactory} from '@contracts/factories/ChainlinkRelayerFactory.sol';
import {DenominatedOracleFactory} from '@contracts/factories/DenominatedOracleFactory.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();
}
}
61 changes: 36 additions & 25 deletions script/Registry.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,42 +60,52 @@ address constant SEPOLIA_ALGEBRA_FARM_CENTER = 0x04e4A5A4E4D2A5a0fb48ECde0bbD555

// -- Mainnet --

address constant MAINNET_PROTOCOL_TOKEN = 0x000D636bD52BFc1B3a699165Ef5aa340BEA8939c;
address constant MAINNET_WETH = 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1;

////////// 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;
address constant MAINNET_DELAYED_ORACLE_FACTORY = 0x9Dd63fA54dEfd8820BCAb3e3cC39aeEc1aE88098;

// 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
////////// RELAYERS //////////
// Camelot
address constant MAINNET_CAMELOT_ODG_WETH_RELAYER = 0xF7Ec9ad3192d4ec1E54d52B3E492B5B66AB02889;

address constant MAINNET_CHAINLINK_ETH_USD_RELAYER = 0x1d2eA5253A3dc201d2275885621c095C6e656e29;
address constant MAINNET_CHAINLINK_RETH_ETH_RELAYER = 0x007E6300C8D98F5B34dFe040248A596482d82B3f;
// 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_CHAINLINK_ARB_USD_RELAYER = 0x2635f731BB6981E72F92A781578952450759F762;
// Denominated
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_DENOMINATED_RETH_USD_ORACLE = 0xE0ac4511A617cBee55ECb62667B08DB6864B9d8e;
address constant MAINNET_DENOMINATED_WSTETH_USD_ORACLE = 0x8746664d1E0F0e61275EF3B52A8a3b3dFC11CcAb;
// Delayed
address constant MAINNET_DELAYED_RETH_USD_ORACLE = 0x0859c0B3EF150fAb129E43B74a63da13F5d2Dd35;
address constant MAINNET_DELAYED_WSTETH_USD_ORACLE = 0xa8dEa011Ed90C53BA4601868Ccc9a36A6F442499;
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;
address constant MAINNET_CHAINLINK_LINK_USD_FEED = 0x86E53CF1B870786351Da77A57575e79CB55812CB;
address constant MAINNET_CHAINLINK_GRT_USD_FEED = 0x0F38D86FceF4955B705F35c9e41d1A16e0637c73;

// Chainlink sequencer feed for Arbitrum One
// Sequencer for Arbitrum One
address constant MAINNET_CHAINLINK_SEQUENCER_FEED = 0xFdB631F5EE196F0ed6FAa767959853A9F217697D;

////////// PARAMS //////////
address constant MAINNET_DEPLOYER = 0xF78dA2A37049627636546E0cFAaB2aD664950917;
uint256 constant MAINNET_ORACLE_DELAY = 1 hours;
uint256 constant MAINNET_CHAINLINK_L2VALIDITY_GRACE_PERIOD = 1 hours;
address constant MAINNET_PROTOCOL_TOKEN = 0x000D636bD52BFc1B3a699165Ef5aa340BEA8939c;
address constant MAINNET_WETH = 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1;
address constant ETH = 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1;
address constant ARB = 0x912CE59144191C1204E64559FE8253a0e49E6548;
address constant ETH_ARB_POOL = 0xe51635ae8136aBAc44906A8f230C2D235E9c195F;
Expand All @@ -106,3 +116,4 @@ address constant MAINNET_DEPLOYER = 0xF78dA2A37049627636546E0cFAaB2aD664950917;
address constant MAINNET_PENDLE_ORACLE = 0x9a9Fa8338dd5E5B2188006f1Cd2Ef26d921650C2;
address constant MAINNET_PENDLE_RETH_MARKET = 0x14FbC760eFaF36781cB0eb3Cb255aD976117B9Bd;
address constant MAINNET_PENDLE_STETH_MARKET = 0x08a152834de126d2ef83D612ff36e4523FD0017F;

8 changes: 4 additions & 4 deletions script/predeployment/DeployRelayers.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ contract DeployODGCamelotRelayerMainnet is CommonMainnet {
function run() public {
vm.startBroadcast(vm.envUint('ARB_MAINNET_DEPLOYER_PK'));
camelotRelayerFactory.deployAlgebraRelayer(
MAINNET_ALGEBRA_FACTORY, MAINNET_PROTOCOL_TOKEN, MAINNET_WETH, uint32(MAINNET_ORACLE_INTERVAL)
MAINNET_ALGEBRA_FACTORY, MAINNET_PROTOCOL_TOKEN, MAINNET_WETH, uint32(MAINNET_ORACLE_DELAY)
);
vm.stopBroadcast();
}
Expand Down Expand Up @@ -56,7 +56,7 @@ contract DeployEthUsdChainlinkRelayerMainnet is CommonMainnet {

function run() public {
vm.startBroadcast(vm.envUint('ARB_MAINNET_DEPLOYER_PK'));
chainlinkRelayerFactory.deployChainlinkRelayer(MAINNET_CHAINLINK_ETH_USD_FEED, MAINNET_ORACLE_INTERVAL);
chainlinkRelayerFactory.deployChainlinkRelayer(MAINNET_CHAINLINK_ETH_USD_FEED, MAINNET_ORACLE_DELAY);
vm.stopBroadcast();
}
}
Expand All @@ -73,7 +73,7 @@ contract DeployRethEthChainlinkRelayerMainnet is CommonMainnet {
function run() public {
vm.startBroadcast(vm.envUint('ARB_MAINNET_DEPLOYER_PK'));
IBaseOracle _chainlinkRethEthPriceFeed =
chainlinkRelayerFactory.deployChainlinkRelayer(MAINNET_CHAINLINK_RETH_ETH_FEED, MAINNET_ORACLE_INTERVAL);
chainlinkRelayerFactory.deployChainlinkRelayer(MAINNET_CHAINLINK_RETH_ETH_FEED, MAINNET_ORACLE_DELAY);

IBaseOracle _rethUsdOracle = denominatedOracleFactory.deployDenominatedOracle(
_chainlinkRethEthPriceFeed, IBaseOracle(MAINNET_CHAINLINK_ETH_USD_RELAYER), false
Expand All @@ -96,7 +96,7 @@ contract DeployWstethEthChainlinkRelayerMainnet is CommonMainnet {
function run() public {
vm.startBroadcast(vm.envUint('ARB_MAINNET_DEPLOYER_PK'));
IBaseOracle _chainlinkWstethEthPriceFeed =
chainlinkRelayerFactory.deployChainlinkRelayer(MAINNET_CHAINLINK_WSTETH_ETH_FEED, MAINNET_ORACLE_INTERVAL);
chainlinkRelayerFactory.deployChainlinkRelayer(MAINNET_CHAINLINK_WSTETH_ETH_FEED, MAINNET_ORACLE_DELAY);

IBaseOracle _wstethUsdOracle = denominatedOracleFactory.deployDenominatedOracle(
_chainlinkWstethEthPriceFeed, IBaseOracle(MAINNET_CHAINLINK_ETH_USD_RELAYER), false
Expand Down
39 changes: 39 additions & 0 deletions src/interfaces/factories/IDelayedOracleFactory.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.7.6;

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

interface IDelayedOracleFactory is IAuthorizable {
// --- Events ---

/**
* @notice Emitted when a new DelayedOracle contract is deployed
* @param _delayedOracle Address of the deployed DelayedOracle contract
* @param _priceSource Address of the price source for the DelayedOracle contract
* @param _updateDelay Delay in seconds to be applied between the price source and the delayed oracle feeds
*/
event NewDelayedOracle(address indexed _delayedOracle, address _priceSource, uint256 _updateDelay);

// --- Methods ---

/**
* @notice Deploys a new DelayedOracle contract
* @param _priceSource Address of the price source for the DelayedOracle contract
* @param _updateDelay Delay in seconds to be applied between the price source and the delayed oracle feeds
* @return _delayedOracle Address of the deployed DelayedOracle contract
*/
function deployDelayedOracle(
IBaseOracle _priceSource,
uint256 _updateDelay
) external returns (IDelayedOracle _delayedOracle);

// --- Views ---

/**
* @notice Getter for the list of DelayedOracle contracts
* @return _delayedOraclesList List of DelayedOracle contracts
*/
function delayedOraclesList() external view returns (address[] memory _delayedOraclesList);
}
56 changes: 56 additions & 0 deletions src/interfaces/oracles/IDelayedOracle.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.7.6;

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

interface IDelayedOracle is IBaseOracle {
// --- Events ---

/**
* @notice Emitted when the oracle is updated
* @param _newMedian The new median value
* @param _lastUpdateTime The timestamp of the update
*/
event UpdateResult(uint256 _newMedian, uint256 _lastUpdateTime);

// --- Structs ---

struct Feed {
// The value of the price feed
uint256 /* WAD */ value;
// Whether the value is valid or not
bool /* bool */ isValid;
}

/**
* @notice Address of the non-delayed price source
* @dev Assumes that the price source is a valid IBaseOracle
*/
function priceSource() external view returns (IBaseOracle _priceSource);

/**
* @notice The next valid price feed, taking effect at the next updateResult call
* @return _result The value in 18 decimals format of the next price feed
* @return _validity Whether the next price feed is valid or not
*/
function getNextResultWithValidity() external view returns (uint256 _result, bool _validity);

/// @notice The delay in seconds that should elapse between updates
function updateDelay() external view returns (uint256 _updateDelay);

/// @notice The timestamp of the last update
function lastUpdateTime() external view returns (uint256 _lastUpdateTime);

/**
* @notice Indicates if a delay has passed since the last update
* @return _ok Whether the oracle should be updated or not
*/
function shouldUpdate() external view returns (bool _ok);

/**
* @notice Updates the current price with the last next price, and reads the next price feed
* @dev Will revert if the delay since last update has not elapsed
* @return _success Whether the update was successful or not
*/
function updateResult() external returns (bool _success);
}

0 comments on commit a1a956e

Please sign in to comment.