Skip to content

Commit

Permalink
feat: add market creation script
Browse files Browse the repository at this point in the history
  • Loading branch information
EperezOk committed May 7, 2024
1 parent fcf8bcc commit d3a6896
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 5 deletions.
50 changes: 50 additions & 0 deletions scripts/Create.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

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

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

contract CreateMarketScript is Script {
// TODO: update values as needed
address constant FACTORY = 0xc10e8E06b1b8DADB8E94120650414AFfedD17aF9;
address constant FEED_FACTORY = 0x0000000000000000000000000000000000000000;
address constant FEED = 0x0000000000000000000000000000000000000000;
uint256[15] MARKET_PARAMS = [
uint256(122000000000), // k
500000000000000000, // lmbda
2500000000000000, // delta
5000000000000000000, // capPayoff
8e23, // capNotional
5000000000000000000, // capLeverage
2592000, // circuitBreakerWindow
66670000000000000000000, // circuitBreakerMintTarget
100000000000000000, // maintenanceMargin
100000000000000000, // maintenanceMarginBurnRate
50000000000000000, // liquidationFeeRate
750000000000000, // tradingFeeRate
1e14, // minCollateral
25000000000000, // priceDriftUpperLimit
250 // averageBlockTime
];

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

OverlayV1Factory factory = OverlayV1Factory(FACTORY);

vm.startBroadcast(DEPLOYER_PK);

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

factory.deployMarket(FEED_FACTORY, FEED, MARKET_PARAMS);

// <!-- END DEPLOYMENT -->

vm.stopBroadcast();
}
}
11 changes: 6 additions & 5 deletions scripts/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ import {OverlayV1Factory} from "../contracts/OverlayV1Factory.sol";
contract DeployScript is Script {
bytes32 constant ADMIN_ROLE = 0x00;

// TODO: update values as needed
address constant GOV = 0x95f972fc4D17a0D343Cd5eaD8d6DCBef5606CA66;
address constant FEE_RECIPIENT = 0xDFafdfF09C1d63257892A8d2F56483588B99315A;
// Ref: https://docs.chain.link/data-feeds/l2-sequencer-feeds#available-networks
address constant SEQUENCER_ORACLE = 0xFdB631F5EE196F0ed6FAa767959853A9F217697D;
uint256 constant GRACE_PERIOD = 1 hours;

function run() external {
uint256 DEPLOYER_PK = vm.envUint("DEPLOYER_PK");
Expand All @@ -29,14 +33,11 @@ contract DeployScript is Script {
OverlayV1Token ovl = new OverlayV1Token();

// 2. Deploy factory contract
// Ref: https://docs.chain.link/data-feeds/l2-sequencer-feeds#available-networks
address sequencerOracle = 0xFdB631F5EE196F0ed6FAa767959853A9F217697D;
uint256 gracePeriod = 1 hours;
OverlayV1Factory factory = new OverlayV1Factory(
address(ovl),
FEE_RECIPIENT,
sequencerOracle,
gracePeriod
SEQUENCER_ORACLE,
GRACE_PERIOD
);

// 3. Grant factory admin role so that it can grant minter + burner roles to markets
Expand Down

0 comments on commit d3a6896

Please sign in to comment.