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

Chainlink relayer with l2 validity #3

Merged
merged 8 commits into from
Jul 6, 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
3 changes: 0 additions & 3 deletions .vscode/settings.json

This file was deleted.

22 changes: 16 additions & 6 deletions gov-input/mainnet/new-DeployChainlinkRelayer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,27 @@
"proposalType": "DeployChainlinkRelayers",
"ODGovernor_Address": "",
"ChainlinkRelayerFactory_Address": "",
"ChainlinkSequencerFeed": "0xFdB631F5EE196F0ed6FAa767959853A9F217697D",
"objectArray": [
{
"symbol": "LINK/USD",
"chainlinkFeed": "0x86E53CF1B870786351Da77A57575e79CB55812CB",
"oracleInterval": "86400"
"chainlinkPriceFeed": "0x86E53CF1B870786351Da77A57575e79CB55812CB",
"staleThreshold": "86400",
"gracePeriod": "3600"
},
{
"symbol": "GRT/USD",
"chainlinkFeed": "0x0F38D86FceF4955B705F35c9e41d1A16e0637c73",
"oracleInterval": "86400"
"chainlinkPriceFeed": "0x0F38D86FceF4955B705F35c9e41d1A16e0637c73",
"staleThreshold": "86400",
"gracePeriod": "3600"
},
{
"symbol": "ETH/USD",
"chainlinkPriceFeed": "0x639Fe6ab55C921f74e7fac1ee960C0B6293ba612",
"staleThreshold": "86400",
"gracePeriod": "3600"
}
],
"arrayLength": "2"
}
"arrayLength": "3",
"PredictedRelayerAddresses": []
}
10 changes: 7 additions & 3 deletions gov-input/sepolia/new-DeployChainlinkRelayer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,25 @@
"proposalType": "DeployChainlinkRelayers",
"ODGovernor_Address": "",
"ChainlinkRelayerFactory_Address": "",
"ChainlinkSequencerFeed": "0xFdB631F5EE196F0ed6FAa767959853A9F217697D",
"objectArray": [
{
"symbol": "LINK/USD",
"chainlinkPriceFeed": "0x86E53CF1B870786351Da77A57575e79CB55812CB",
"oracleInterval": "86400"
"staleThreshold": "86400",
"gracePeriod": "3600"
},
{
"symbol": "GRT/USD",
"chainlinkPriceFeed": "0x0F38D86FceF4955B705F35c9e41d1A16e0637c73",
"oracleInterval": "86400"
"staleThreshold": "86400",
"gracePeriod": "3600"
},
{
"symbol": "ETH/USD",
"chainlinkPriceFeed": "0x639Fe6ab55C921f74e7fac1ee960C0B6293ba612",
"oracleInterval": "86400"
"staleThreshold": "86400",
"gracePeriod": "3600"
}
],
"arrayLength": "3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,36 +35,30 @@
"0x34463c60574554480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000001aba4714957d300d0e549208b31adb1000000000000000000000000000000000000023084f676940b7915149bd08b30d000000000000",
"0x34463c605745544800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000033b2e3ca65dca26e20d5eda",
"0x34463c60574554480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000060000000000000000000000000293b702362918e990dd5f48a80fb139fead642630000000000000000000000000000000000000000000000000e92596fd6290000000000000000000000000022361d8afcc93343e962029a7edab2000000000000",
"0x34463c60574554480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000060000000000000000000000000562cce2f4dc383862dc6a926af10deff5fcd172f000000000000000000000000000000000000000003e09de2596099e2b0000000000000000000000000000000000000000000000003b741f8eafc93793e000000",
"0x35b2815300000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020000000000000000000000000293b702362918e990dd5f48a80fb139fead64263",
"0xd94d420800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000020000000000000000000000000293b702362918e990dd5f48a80fb139fead64263"
"0x34463c60574554480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000060000000000000000000000000562cce2f4dc383862dc6a926af10deff5fcd172f000000000000000000000000000000000000000003e09de2596099e2b0000000000000000000000000000000000000000000000003b741f8eafc93793e000000"
],
"chainid": "42161",
"description": "Add WETH collateral",
"descriptionHash": "0xfd136854ab5ad7612b20257dbb15bbf69f738244d3f9eb544096a2bf7c8f04ef",
"network": "mainnet",
"newCollateralAddress": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
"newCollateralType": "WETH",
"proposalId": 34858172628765133262997362556758347679155114160723424965616922864986482020293,
"proposalId": 97290491579890362738323444422626923608004417491310716055050700511259453325225,
"proposalType": "AddCollateral",
"targets": [
"0xa83c0f1e9eD8E383919Dde0fC90744ae370EB7B3",
"0x5dc1E86361faC018f24Ae0D1E5eB01D70AB32A82",
"0xEff45E8e2353893BD0558bD5892A42786E9142F1",
"0xc93F938A95488a03b976A15B20fAcFD52D087fB2",
"0x17e546dDCE2EA8A74Bd667269457A2e80b309965",
"0x7404fc1F3796748FAE17011b57Fad9713185c1d6",
"0xEff45E8e2353893BD0558bD5892A42786E9142F1",
"0xEff45E8e2353893BD0558bD5892A42786E9142F1"
"0x7404fc1F3796748FAE17011b57Fad9713185c1d6"
],
"values": [
0,
0,
0,
0,
0,
0,
0,
0
]
}
61 changes: 61 additions & 0 deletions gov-output/sepolia/deploy-chainlink-relayer-61857469.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"ChainlinkRelayerFactory_Address": "0x555691C860015a5CE8748296fbbAa624410F55A4",
"ChainlinkSequencerFeed": "0xFdB631F5EE196F0ed6FAa767959853A9F217697D",
"ODGovernor_Address": "0x69ae232E574352232aB8678869eAA3BEBd885211",
"PredictedRelayerAddresses": [
{
"symbol": "LINK/USD",
"address": "0x3Dc02C28D29D6A4D13dE03E7c596a94c76f7600a"
},
{
"symbol": "GRT/USD",
"address": "0xf589519a17bDC25749AFAcbC6BAFdd05BF5d24Af"
},
{
"symbol": "ETH/USD",
"address": "0x33660aB6E38F6D8011Eca7AAa6F3CC7ef6380d91"
}
],
"arrayLength": "3",
"calldatas": [
"0x251ad9a500000000000000000000000086e53cf1b870786351da77a57575e79cb55812cb000000000000000000000000fdb631f5ee196f0ed6faa767959853a9f217697d00000000000000000000000000000000000000000000000000000000000151800000000000000000000000000000000000000000000000000000000000000e10",
"0x251ad9a50000000000000000000000000f38d86fcef4955b705f35c9e41d1a16e0637c73000000000000000000000000fdb631f5ee196f0ed6faa767959853a9f217697d00000000000000000000000000000000000000000000000000000000000151800000000000000000000000000000000000000000000000000000000000000e10",
"0x251ad9a5000000000000000000000000639fe6ab55c921f74e7fac1ee960c0b6293ba612000000000000000000000000fdb631f5ee196f0ed6faa767959853a9f217697d00000000000000000000000000000000000000000000000000000000000151800000000000000000000000000000000000000000000000000000000000000e10"
],
"chainid": 421614,
"description": "Deploy new chainlink relayers",
"descriptionHash": "0x03087660ad65289d7f9f35887f72e304a35460e94606f1c40d6d3884e0e36a4c",
"network": "sepolia",
"objectArray": [
{
"symbol": "LINK/USD",
"chainlinkPriceFeed": "0x86E53CF1B870786351Da77A57575e79CB55812CB",
"staleThreshold": "86400",
"gracePeriod": "3600"
},
{
"symbol": "GRT/USD",
"chainlinkPriceFeed": "0x0F38D86FceF4955B705F35c9e41d1A16e0637c73",
"staleThreshold": "86400",
"gracePeriod": "3600"
},
{
"symbol": "ETH/USD",
"chainlinkPriceFeed": "0x639Fe6ab55C921f74e7fac1ee960C0B6293ba612",
"staleThreshold": "86400",
"gracePeriod": "3600"
}
],
"proposalId": 61857469553398489852308972851954168900597935201047788453491803085690968636070,
"proposalType": "DeployChainlinkRelayers",
"targets": [
"0x555691C860015a5CE8748296fbbAa624410F55A4",
"0x555691C860015a5CE8748296fbbAa624410F55A4",
"0x555691C860015a5CE8748296fbbAa624410F55A4"
],
"values": [
0,
0,
0
]
}
16 changes: 3 additions & 13 deletions src/contracts/Generate/GenerateAddCollateralProposal.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import {Generator} from '../Generator.s.sol';
import {IGlobalSettlement} from '@opendollar/contracts/settlement/GlobalSettlement.sol';
import {ICollateralJoinFactory} from '@opendollar/interfaces/factories/ICollateralJoinFactory.sol';
import {IAuthorizable} from '@opendollar/interfaces/utils/IAuthorizable.sol';

Check warning on line 9 in src/contracts/Generate/GenerateAddCollateralProposal.s.sol

View workflow job for this annotation

GitHub Actions / Run Linters (20.x)

imported name IAuthorizable is not used

Check warning on line 9 in src/contracts/Generate/GenerateAddCollateralProposal.s.sol

View workflow job for this annotation

GitHub Actions / Run Linters (20.x)

imported name IAuthorizable is not used
import {IModifiablePerCollateral} from '@opendollar/interfaces/utils/IModifiablePerCollateral.sol';
import {ICollateralAuctionHouse} from '@opendollar/interfaces/ICollateralAuctionHouse.sol';
import {ISAFEEngine} from '@opendollar/interfaces/ISAFEEngine.sol';
Expand All @@ -14,9 +14,9 @@
import {ILiquidationEngine} from '@opendollar/interfaces/ILiquidationEngine.sol';
import {IOracleRelayer} from '@opendollar/contracts/OracleRelayer.sol';
import {IDelayedOracle} from '@opendollar/interfaces/oracles/IDelayedOracle.sol';
import {CollateralAuctionHouseChild} from '@opendollar/contracts/factories/CollateralAuctionHouseChild.sol';

Check warning on line 17 in src/contracts/Generate/GenerateAddCollateralProposal.s.sol

View workflow job for this annotation

GitHub Actions / Run Linters (20.x)

imported name CollateralAuctionHouseChild is not used

Check warning on line 17 in src/contracts/Generate/GenerateAddCollateralProposal.s.sol

View workflow job for this annotation

GitHub Actions / Run Linters (20.x)

imported name CollateralAuctionHouseChild is not used
import 'forge-std/StdJson.sol';

Check warning on line 18 in src/contracts/Generate/GenerateAddCollateralProposal.s.sol

View workflow job for this annotation

GitHub Actions / Run Linters (20.x)

global import of path forge-std/StdJson.sol is not allowed. Specify names to import individually or bind all exports of the module into a name (import "path" as Name)

Check warning on line 18 in src/contracts/Generate/GenerateAddCollateralProposal.s.sol

View workflow job for this annotation

GitHub Actions / Run Linters (20.x)

Import 'forge-std/StdJson.sol' in contract GenerateAddCollateralProposal should be declared as import {contract_to_import} from 'forge-std/StdJson.sol';

Check warning on line 18 in src/contracts/Generate/GenerateAddCollateralProposal.s.sol

View workflow job for this annotation

GitHub Actions / Run Linters (20.x)

global import of path forge-std/StdJson.sol is not allowed. Specify names to import individually or bind all exports of the module into a name (import "path" as Name)

Check warning on line 18 in src/contracts/Generate/GenerateAddCollateralProposal.s.sol

View workflow job for this annotation

GitHub Actions / Run Linters (20.x)

Import 'forge-std/StdJson.sol' in contract GenerateAddCollateralProposal should be declared as import {contract_to_import} from 'forge-std/StdJson.sol';
import 'forge-std/console2.sol';

Check failure on line 19 in src/contracts/Generate/GenerateAddCollateralProposal.s.sol

View workflow job for this annotation

GitHub Actions / Run Linters (20.x)

Unexpected import of console file

Check warning on line 19 in src/contracts/Generate/GenerateAddCollateralProposal.s.sol

View workflow job for this annotation

GitHub Actions / Run Linters (20.x)

global import of path forge-std/console2.sol is not allowed. Specify names to import individually or bind all exports of the module into a name (import "path" as Name)

Check failure on line 19 in src/contracts/Generate/GenerateAddCollateralProposal.s.sol

View workflow job for this annotation

GitHub Actions / Run Linters (20.x)

Unexpected import of console file

Check warning on line 19 in src/contracts/Generate/GenerateAddCollateralProposal.s.sol

View workflow job for this annotation

GitHub Actions / Run Linters (20.x)

global import of path forge-std/console2.sol is not allowed. Specify names to import individually or bind all exports of the module into a name (import "path" as Name)

/// @title ProposeAddCollateral Script
/// @author OpenDollar
Expand Down Expand Up @@ -120,32 +120,28 @@
ODGovernor gov = ODGovernor(payable(governanceAddress));
IGlobalSettlement globalSettlement = IGlobalSettlement(globalSettlementAddress);

address[] memory targets = new address[](8);
address[] memory targets = new address[](6);
{
targets[0] = address(globalSettlement.collateralJoinFactory());
targets[1] = address(globalSettlement.collateralAuctionHouseFactory());
targets[2] = safeEngine;
targets[3] = taxCollector;
targets[4] = liquidationEngine;
targets[5] = oracleRelayer;
targets[6] = safeEngine;
targets[7] = safeEngine;
}
// No values needed
uint256[] memory values = new uint256[](8);
uint256[] memory values = new uint256[](6);
{
values[0] = 0;
values[1] = 0;
values[2] = 0;
values[3] = 0;
values[4] = 0;
values[5] = 0;
values[6] = 0;
values[7] = 0;
}
// Get calldata for:

bytes[] memory calldatas = new bytes[](8);
bytes[] memory calldatas = new bytes[](6);

calldatas[0] = abi.encodeWithSelector(ICollateralJoinFactory.deployCollateralJoin.selector, newCType, newCAddress);

Expand All @@ -164,12 +160,6 @@
calldatas[5] = abi.encodeWithSelector(
IModifiablePerCollateral.initializeCollateralType.selector, newCType, abi.encode(_oracleCParams)
);
calldatas[6] = abi.encodeWithSelector(
IAuthorizable.addAuthorization.selector, abi.encode(_liquidationEngineCParams.collateralAuctionHouse)
);
calldatas[7] = abi.encodeWithSelector(
ISAFEEngine.approveSAFEModification.selector, abi.encode(_liquidationEngineCParams.collateralAuctionHouse)
);

// Get the descriptionHash
bytes32 descriptionHash = keccak256(bytes(description));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ pragma solidity 0.8.20;

import {JSONScript} from '../helpers/JSONScript.s.sol';
import {ODGovernor} from '@opendollar/contracts/gov/ODGovernor.sol';
import {IERC20} from '@openzeppelin/token/ERC20/IERC20.sol';
import {Generator} from '../Generator.s.sol';
import {Strings} from '@openzeppelin/utils/Strings.sol';
import {IChainlinkRelayerFactory} from '@opendollar/interfaces/factories/IChainlinkRelayerFactory.sol';
import {IChainlinkRelayerFactory} from '../interfaces/IChainlinkRelayerFactory.sol';
import 'forge-std/StdJson.sol';

/// @title GenerateDeployChainlinkRelayersProposal Script
Expand All @@ -19,29 +18,34 @@ contract GenerateDeployChainlinkRelayersProposal is Generator, JSONScript {
string public description;
address public governanceAddress;
address public chainlinkRelayerFactory;
address public chainlinkSequencerFeed;
address[] public chainlinkFeed;
uint256[] public oracleInterval;
uint256[] public staleThreshold;
uint256[] public gracePeriod;

function _loadBaseData(string memory json) internal override {
governanceAddress = json.readAddress(string(abi.encodePacked('.ODGovernor_Address:')));
description = json.readString(string(abi.encodePacked('.description')));
chainlinkRelayerFactory = json.readAddress(string(abi.encodePacked('.ChainlinkRelayerFactory_Address')));
chainlinkSequencerFeed = json.readAddress(string(abi.encodePacked('.ChainlinkSequencerFeed')));
uint256 len = json.readUint(string(abi.encodePacked('.arrayLength')));

for (uint256 i; i < len; i++) {
string memory index = Strings.toString(i);
address feed = json.readAddress(string(abi.encodePacked('.objectArray[', index, '].chainlinkPriceFeed')));
uint256 interval = json.readUint(string(abi.encodePacked('.objectArray[', index, '].oracleInterval')));
uint256 interval = json.readUint(string(abi.encodePacked('.objectArray[', index, '].staleThreshold')));
uint256 grace = json.readUint(string(abi.encodePacked('.objectArray[', index, '].gracePeriod')));
Comment on lines +36 to +37
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider keeping variables names the same throughout

chainlinkFeed.push(feed);
oracleInterval.push(interval);
staleThreshold.push(interval);
gracePeriod.push(grace);
}
}

function _generateProposal() internal override {
ODGovernor gov = ODGovernor(payable(governanceAddress));

uint256 len = chainlinkFeed.length;
require(len == oracleInterval.length, 'CHAINLINK RELAYER: mismatched array lengths');
require(len == staleThreshold.length, 'CHAINLINK RELAYER: mismatched array lengths');

address[] memory targets = new address[](len);
uint256[] memory values = new uint256[](len);
Expand All @@ -50,7 +54,11 @@ contract GenerateDeployChainlinkRelayersProposal is Generator, JSONScript {
for (uint256 i = 0; i < len; i++) {
// encode relayer factory function data
calldatas[i] = abi.encodeWithSelector(
IChainlinkRelayerFactory.deployChainlinkRelayer.selector, chainlinkFeed[i], oracleInterval[i]
IChainlinkRelayerFactory.deployChainlinkRelayerWithL2Validity.selector,
chainlinkFeed[i],
chainlinkSequencerFeed,
staleThreshold[i],
gracePeriod[i]
);
targets[i] = chainlinkRelayerFactory;
values[i] = 0; // value is always 0
Expand Down
18 changes: 18 additions & 0 deletions src/contracts/interfaces/IChainlinkRelayerFactory.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.20;

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

interface IChainlinkRelayerFactory {
// --- Events ---
event NewChainlinkRelayer(address indexed _chainlinkRelayer, address _aggregator, uint256 _staleThreshold);

function deployChainlinkRelayer(address _aggregator, uint256 _staleThreshold) external returns (IBaseOracle _relayer);

function deployChainlinkRelayerWithL2Validity(
address _priceAggregator,
address _sequencerAggregator,
uint256 _staleThreshold,
uint256 _gracePeriod
) external returns (IBaseOracle _chainlinkRelayer);
}
Loading