-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into add-pendle-relayers
- Loading branch information
Showing
7 changed files
with
212 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |