forked from Synthetixio/synthetix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBinaryOptionMarketFactory.sol
64 lines (50 loc) · 1.95 KB
/
BinaryOptionMarketFactory.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
pragma solidity ^0.5.16;
// Inheritance
import "./Owned.sol";
import "./MixinResolver.sol";
// Internal references
import "./BinaryOptionMarket.sol";
// https://docs.synthetix.io/contracts/source/contracts/binaryoptionmarketfactory
contract BinaryOptionMarketFactory is Owned, MixinResolver {
/* ========== STATE VARIABLES ========== */
/* ---------- Address Resolver Configuration ---------- */
bytes32 internal constant CONTRACT_BINARYOPTIONMARKETMANAGER = "BinaryOptionMarketManager";
/* ========== CONSTRUCTOR ========== */
constructor(address _owner, address _resolver) public Owned(_owner) MixinResolver(_resolver) {}
/* ========== VIEWS ========== */
function resolverAddressesRequired() public view returns (bytes32[] memory addresses) {
addresses = new bytes32[](1);
addresses[0] = CONTRACT_BINARYOPTIONMARKETMANAGER;
}
/* ---------- Related Contracts ---------- */
function _manager() internal view returns (address) {
return requireAndGetAddress(CONTRACT_BINARYOPTIONMARKETMANAGER);
}
/* ========== MUTATIVE FUNCTIONS ========== */
function createMarket(
address creator,
uint[2] calldata creatorLimits,
bytes32 oracleKey,
uint strikePrice,
bool refundsEnabled,
uint[3] calldata times, // [biddingEnd, maturity, expiry]
uint[2] calldata bids, // [longBid, shortBid]
uint[3] calldata fees // [poolFee, creatorFee, refundFee]
) external returns (BinaryOptionMarket) {
address manager = _manager();
require(address(manager) == msg.sender, "Only permitted by the manager.");
return
new BinaryOptionMarket(
manager,
creator,
address(resolver),
creatorLimits,
oracleKey,
strikePrice,
refundsEnabled,
times,
bids,
fees
);
}
}