Skip to content

Commit

Permalink
feat: deployment script for generic rate provider
Browse files Browse the repository at this point in the history
  • Loading branch information
junkim012 committed Aug 22, 2024
1 parent 8fcbdd6 commit 1150638
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions script/deploy/DeployGenericRateProvider.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pragma solidity 0.8.21;
import { GenericRateProvider } from "./../../src/helper/GenericRateProvider.sol";
import { BaseScript } from "../Base.s.sol";
import { stdJson as StdJson } from "@forge-std/StdJson.sol";
import { console2 } from "forge-std/console2.sol";

using StdJson for string;

Expand All @@ -12,21 +13,28 @@ contract DeployGenericRateProvider is BaseScript {
string configPath = "./deployment-config/rates/DeployGenericRateProvider.json";
string config = vm.readFile(configPath);

uint256 expectedMin = config.readUint("expectedMin");
uint256 expectedMax = config.readUint("expectedMax");
address target = config.readAddress("target");
string signature = config.readString("signature");
bytes32 salt = config.readBytes32("salt");
uint256 expectedMin = config.readUint(".expectedMin");
uint256 expectedMax = config.readUint(".expectedMax");
address target = config.readAddress(".target");
string signature = config.readString(".signature");
bytes32 salt = config.readBytes32(".salt");

function run() public returns (address rateProvider) {
function run() public returns (GenericRateProvider rateProvider) {
bytes4 functionSig = bytes4(keccak256(bytes(signature)));
console2.logBytes4(functionSig);

bytes memory creationCode = type(GenericRateProvider).creationCode;
GenericRateProvider rateProvider =
GenericRateProvider(CREATEX.deployCreate3(salt, abi.encodePacked(functionSig)));

rateProvider = GenericRateProvider(
CREATEX.deployCreate3(
salt, abi.encodePacked(creationCode, abi.encode(target, functionSig, 0, 0, 0, 0, 0, 0, 0, 0))
)
);

uint256 rate = rateProvider.getRate();

console2.log("rate: ", rate);

require(rate != 0, "rate must not be zero");
require(rate >= expectedMin, "rate must be greater than or equal to min");
require(rate <= expectedMax, "rate must be less than or equal to max");
Expand Down

0 comments on commit 1150638

Please sign in to comment.