Skip to content

Commit

Permalink
Merge pull request #193 from PeggyJV/zaki/ETHXUpdates
Browse files Browse the repository at this point in the history
Add EthX price feed
  • Loading branch information
zmanian authored Aug 23, 2024
2 parents 5b3d89a + 4541c1c commit 6d25401
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 0 deletions.
56 changes: 56 additions & 0 deletions script/Mainnet/production/switchETHXPriceFeed.part2.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.21;

import { Math } from "src/utils/Math.sol";
import { Deployer } from "src/Deployer.sol";
import { ERC4626 } from "@solmate/mixins/ERC4626.sol";
import { ERC20 } from "@solmate/tokens/ERC20.sol";
import { Registry } from "src/Registry.sol";
import { PriceRouter } from "src/modules/price-router/PriceRouter.sol";
import { IChainlinkAggregator } from "src/interfaces/external/IChainlinkAggregator.sol";
import { ERC20Adaptor } from "src/modules/adaptors/ERC20Adaptor.sol";

import { MainnetAddresses } from "test/resources/MainnetAddresses.sol";

import "forge-std/Script.sol";

/**
* @dev Run
* `source .env && forge script script/Mainnet/production/switchETHXPriceFeed.part2.s.sol:switchEthXPriceFeed --rpc-url $MAINNET_RPC_URL --sender $MULTI_SIG --with-gas-price 25000000000`
*/
contract switchEthXPriceFeed is Script, MainnetAddresses {


Registry public registry = Registry(0xEED68C267E9313a6ED6ee08de08c9F68dee44476);
PriceRouter public priceRouter = PriceRouter(0xA1A0bc3D59e4ee5840c9530e49Bdc2d1f88AaF92);


uint8 public constant CHAINLINK_DERIVATIVE = 1;
uint8 public constant TWAP_DERIVATIVE = 2;
uint8 public constant EXTENSION_DERIVATIVE = 3;

function run() external {

//Complete EDIT asset

uint256 ethx_price = uint256(IChainlinkAggregator(ETHX_ETH_FEED).latestAnswer());

uint256 eth_price = uint256(IChainlinkAggregator(WETH_USD_FEED).latestAnswer());

uint256 price = ethx_price * eth_price/1e18;

PriceRouter.AssetSettings memory settings;


settings = PriceRouter.AssetSettings(CHAINLINK_DERIVATIVE, ETHX_ETH_FEED);
PriceRouter.ChainlinkDerivativeStorage memory stor;
stor.inETH = true;

vm.startBroadcast();

priceRouter.completeEditAsset(ETHX, settings, abi.encode(stor), price);

vm.stopBroadcast();
}

}
50 changes: 50 additions & 0 deletions script/Mainnet/production/switchETHXPriceFeed.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.21;

import { Math } from "src/utils/Math.sol";
import { Deployer } from "src/Deployer.sol";
import { ERC4626 } from "@solmate/mixins/ERC4626.sol";
import { ERC20 } from "@solmate/tokens/ERC20.sol";
import { Registry } from "src/Registry.sol";
import { PriceRouter } from "src/modules/price-router/PriceRouter.sol";
import { IChainlinkAggregator } from "src/interfaces/external/IChainlinkAggregator.sol";
import { ERC20Adaptor } from "src/modules/adaptors/ERC20Adaptor.sol";

import { MainnetAddresses } from "test/resources/MainnetAddresses.sol";

import "forge-std/Script.sol";

/**
* @dev Run
* `source .env && forge script script/Mainnet/production/switchETHXPriceFeed.s.sol:swithEthXPriceFeed --rpc-url $MAINNET_RPC_URL --sender $MULTI_SIG --with-gas-price 25000000000`
*/
contract swithEthXPriceFeed is Script, MainnetAddresses {


Registry public registry = Registry(0xEED68C267E9313a6ED6ee08de08c9F68dee44476);
PriceRouter public priceRouter = PriceRouter(0xA1A0bc3D59e4ee5840c9530e49Bdc2d1f88AaF92);


uint8 public constant CHAINLINK_DERIVATIVE = 1;
uint8 public constant TWAP_DERIVATIVE = 2;
uint8 public constant EXTENSION_DERIVATIVE = 3;

function run() external {

//Start EDIT asset

PriceRouter.AssetSettings memory settings;


settings = PriceRouter.AssetSettings(CHAINLINK_DERIVATIVE, ETHX_ETH_FEED);
PriceRouter.ChainlinkDerivativeStorage memory stor;
stor.inETH = true;

vm.startBroadcast();

priceRouter.startEditAsset(ETHX, settings, abi.encode(stor));

vm.stopBroadcast();
}

}

0 comments on commit 6d25401

Please sign in to comment.