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

added deploy oracle script and a add oracle to registry script #6

Merged
merged 1 commit into from
Aug 2, 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
4 changes: 4 additions & 0 deletions script/Common.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ import {IAuthorizable} from '@interfaces/utils/IAuthorizable.sol';
import {ChainlinkRelayerFactory} from '@contracts/factories/ChainlinkRelayerFactory.sol';
import {DenominatedOracleFactory} from '@contracts/factories/DenominatedOracleFactory.sol';
import {PendleRelayerFactory} from '@contracts/factories/pendle/PendleRelayerFactory.sol';
import {GmxRelayerFactory} from '@contracts/factories/gmx/GmxRelayerFactory.sol';
import {OracleRegistry} from '@contracts/oracles/OracleRegistry.sol';
import {IDelayedOracleFactory} from '@interfaces/factories/IDelayedOracleFactory.sol';

abstract contract CommonMainnet is Script {
ChainlinkRelayerFactory public chainlinkRelayerFactory = ChainlinkRelayerFactory(MAINNET_CHAINLINK_RELAYER_FACTORY);
DenominatedOracleFactory public denominatedOracleFactory =
DenominatedOracleFactory(MAINNET_DENOMINATED_ORACLE_FACTORY);
PendleRelayerFactory public pendleRelayerFactory = PendleRelayerFactory(MAINNET_PENDLE_RELAYER_FACTORY);
GmxRelayerFactory public gmxRelayerFactory = GmxRelayerFactory(MAINNET_GMX_RELAYER_FACTORY);
IDelayedOracleFactory public delayedOracleFactory = IDelayedOracleFactory(MAINNET_DELAYED_ORACLE_FACTORY);
OracleRegistry public oracleRegistry = OracleRegistry(MAINNET_ORACLE_REGISTRY);
}

abstract contract CommonSepolia is Script {
Expand Down
7 changes: 6 additions & 1 deletion script/Registry.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ address constant MAINNET_CHAINLINK_RELAYER_FACTORY = 0x06C32500489C28Bd57c551afd
address constant MAINNET_DENOMINATED_ORACLE_FACTORY = 0xBF760b23d2ef3615cec549F22b95a34DB0F8f5CD;
address constant MAINNET_DELAYED_ORACLE_FACTORY = 0x9Dd63fA54dEfd8820BCAb3e3cC39aeEc1aE88098;
address constant MAINNET_PENDLE_RELAYER_FACTORY = 0x0D8CBBbd6e4984caA310d80e66cc434D71e9D118;
address constant MAINNET_GMX_RELAYER_FACTORY = 0x0000000000000000000000000000000000000000;

////////// ORACLE REGISTRY ////////////
address constant MAINNET_ORACLE_REGISTRY = 0x0000000000000000000000000000000000000000;

////////// STANDARD RELAYERS //////////
// Camelot
Expand Down Expand Up @@ -122,8 +126,9 @@ address constant MAINNET_PENDLE_WSTETH_MARKET = 0x08a152834de126d2ef83D612ff36e4
////////// GMX //////////
address constant MAINNET_GMX_DATA_STORE = 0xFD70de6b91282D8017aA4E741e9Ae325CAb992d8;
address constant MAINNET_GMX_READER = 0x5Ca84c34a381434786738735265b9f3FD814b824;

// GM-ETH Perp Market
address constant MAINNET_GMX_WETH_PERP_MARKET_TOKEN = 0x70d95587d40A2caf56bd97485aB3Eec10Bee6336;
address constant MAINNET_GMX_WETH_PERP_INDEX_TOKEN = 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1; //WETH
address constant MAINNET_GMX_WETH_PERP_LONG_TOKEN = 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1; //WETH
address constant MAINNET_GMX_WETH_PERP_shortToken = 0xaf88d065e77c8cC2239327C5EDb3A432268e5831; //usdc
address constant MAINNET_GMX_WETH_PERP_SHORT_TOKEN = 0xaf88d065e77c8cC2239327C5EDb3A432268e5831; //usdc
23 changes: 23 additions & 0 deletions script/oracles/DeployGmXOracle.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.20;

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

// BROADCAST
// source .env && forge script DeployGmxWethMarketRelayerMainnet --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 DeployGmxWethMarketRelayerMainnet --with-gas-price 2000000000 -vvvvv --rpc-url $ARB_MAINNET_RPC --account defaultKey --sender $DEFAULT_KEY_PUBLIC
contract DeployGmxWethMarketRelayerMainnet is CommonMainnet {
function run() public {
vm.startBroadcast();
IBaseOracle _gmWethPerpMarketOracle = gmxRelayerFactory.deployGmxGmRelayerWithRegistry(
MAINNET_GMX_WETH_PERP_MARKET_TOKEN, MAINNET_GMX_READER, MAINNET_GMX_DATA_STORE, MAINNET_ORACLE_REGISTRY
);

console2.log('GM WEth perp market oracle deployed at: ', address(_gmWethPerpMarketOracle));
vm.stopBroadcast();
}
}
25 changes: 24 additions & 1 deletion script/oracles/DeployOracleRegistry.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,34 @@ contract DeployOracleRegistryMainnet is Script, CommonMainnet {
// add wsteth oracle
tokens.push(ARB);
oracles.push(IBaseOracle(MAINNET_CHAINLINK_ARB_USD_RELAYER));
//add usdc oracle
tokens.push(USDC);
oracles.push(IBaseOracle(MAINNET_CHAINLINK_USDC_USD_FEED));

address oracleRegistry = address(new OracleRegistry(tokens, oracles));

console2.log('New Oracle Registry deployed at:', oracleRegistry);
console2.log('New Oracle Registry deployed at: ', oracleRegistry);

vm.stopBroadcast();
}
}

// BROADCAST
// source .env && forge script AddOracleToRegisty --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 AddOracleToRegisty --with-gas-price 2000000000 -vvvvv --rpc-url $ARB_MAINNET_RPC --account defaultKey --sender $DEFAULT_KEY_PUBLIC

contract AddOracleToRegisty is Script, CommonMainnet {
address tokenToAdd = 0x0000000000000000000000000000000000000000; // the address of the token that the oracle is providing the price for
IBaseOracle public oracleToAdd = IBaseOracle(0x0000000000000000000000000000000000000000); // the base oracle denominated in usd of for the above token price

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

oracleRegistry.addOracle(tokenToAdd, oracleToAdd);

console2.log('New oracle added to registry');
vm.stopBroadcast();
}
}
Loading