Skip to content

Commit

Permalink
feat: add chainlink feed scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
EperezOk committed May 7, 2024
1 parent a0aaafa commit c7ddc29
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
35 changes: 35 additions & 0 deletions scripts/feeds/chainlink/Create.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {Script, console2} from "forge-std/Script.sol";
import {OverlayV1ChainlinkFeedFactory} from "contracts/feeds/chainlink/OverlayV1ChainlinkFeedFactory.sol";

// 1. Set required environment variables: ETHERSCAN_API_KEY, DEPLOYER_PK, RPC.
// 2. Run with:
// $ source .env
// $ forge script scripts/Create.s.sol:CreateFeed --rpc-url $RPC --verify -vvvv --broadcast

contract CreateFeed is Script {
// TODO: update values as needed
address constant FEED_FACTORY = 0x0000000000000000000000000000000000000000;
address constant AGGREGATOR = 0x0000000000000000000000000000000000000000;
uint256 constant HEARTBEAT = 120 minutes;

function run() external {
uint256 DEPLOYER_PK = vm.envUint("DEPLOYER_PK");

vm.startBroadcast(DEPLOYER_PK);

OverlayV1ChainlinkFeedFactory feedFactory = OverlayV1ChainlinkFeedFactory(FEED_FACTORY);

// <!---- START DEPLOYMENT ---->

address feed = feedFactory.deployFeed(AGGREGATOR, HEARTBEAT);

// <!-- END DEPLOYMENT -->

vm.stopBroadcast();

console2.log("Feed deployed at:", feed);
}
}
33 changes: 33 additions & 0 deletions scripts/feeds/chainlink/Deploy.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {Script, console2} from "forge-std/Script.sol";
import {OverlayV1ChainlinkFeedFactory} from "contracts/feeds/chainlink/OverlayV1ChainlinkFeedFactory.sol";

// 1. Set required environment variables: ETHERSCAN_API_KEY, DEPLOYER_PK, RPC.
// 2. Run with:
// $ source .env
// $ forge script scripts/Deploy.s.sol:DeployFeedFactory --rpc-url $RPC --verify -vvvv --broadcast

contract DeployFeedFactory is Script {
// TODO: update values as needed
address constant OVL = 0x0000000000000000000000000000000000000000;
uint256 constant MICRO_WINDOW = 600;
uint256 constant MACRO_WINDOW = 3600;

function run() external {
uint256 DEPLOYER_PK = vm.envUint("DEPLOYER_PK");

vm.startBroadcast(DEPLOYER_PK);

// <!---- START DEPLOYMENT ---->

OverlayV1ChainlinkFeedFactory feedFactory = new OverlayV1ChainlinkFeedFactory(OVL, MICRO_WINDOW, MACRO_WINDOW);

// <!-- END DEPLOYMENT -->

vm.stopBroadcast();

console2.log("FeedFactory deployed at:", address(feedFactory));
}
}

0 comments on commit c7ddc29

Please sign in to comment.