Skip to content

Commit

Permalink
Merge branch 'develop' into feature/update-hardhat
Browse files Browse the repository at this point in the history
  • Loading branch information
ggviana committed Apr 19, 2021
2 parents be32c31 + aec68d5 commit a6876fa
Show file tree
Hide file tree
Showing 12 changed files with 120 additions and 23 deletions.
17 changes: 15 additions & 2 deletions abi/OptionAMMFactory.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
{
"inputs": [
{
"internalType": "address",
"name": "configurationManager",
"internalType": "contract IConfigurationManager",
"name": "_configurationManager",
"type": "address"
}
],
Expand Down Expand Up @@ -35,6 +35,19 @@
"name": "PoolCreated",
"type": "event"
},
{
"inputs": [],
"name": "configurationManager",
"outputs": [
{
"internalType": "contract IConfigurationManager",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
Expand Down
17 changes: 15 additions & 2 deletions abi/OptionHelper.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
{
"inputs": [
{
"internalType": "address",
"name": "configurationManager",
"internalType": "contract IConfigurationManager",
"name": "_configurationManager",
"type": "address"
}
],
Expand Down Expand Up @@ -224,6 +224,19 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "configurationManager",
"outputs": [
{
"internalType": "contract IConfigurationManager",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
Expand Down
13 changes: 13 additions & 0 deletions abi/PodCall.json
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,19 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "configurationManager",
"outputs": [
{
"internalType": "contract IConfigurationManager",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "decimals",
Expand Down
15 changes: 14 additions & 1 deletion abi/PodOption.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
},
{
"internalType": "contract IConfigurationManager",
"name": "configurationManager",
"name": "_configurationManager",
"type": "address"
}
],
Expand Down Expand Up @@ -292,6 +292,19 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "configurationManager",
"outputs": [
{
"internalType": "contract IConfigurationManager",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "decimals",
Expand Down
13 changes: 13 additions & 0 deletions abi/PodPut.json
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,19 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "configurationManager",
"outputs": [
{
"internalType": "contract IConfigurationManager",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "decimals",
Expand Down
13 changes: 13 additions & 0 deletions abi/WPodCall.json
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,19 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "configurationManager",
"outputs": [
{
"internalType": "contract IConfigurationManager",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "decimals",
Expand Down
13 changes: 13 additions & 0 deletions abi/WPodPut.json
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,19 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "configurationManager",
"outputs": [
{
"internalType": "contract IConfigurationManager",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "decimals",
Expand Down
13 changes: 8 additions & 5 deletions contracts/amm/OptionAMMFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@ contract OptionAMMFactory is IOptionAMMFactory {
/**
* @dev store globally accessed configurations
*/
IConfigurationManager private _configurationManager;
IConfigurationManager public immutable configurationManager;

event PoolCreated(address indexed deployer, address pool, address option);

constructor(address configurationManager) public {
require(Address.isContract(configurationManager), "OptionAMMFactory: Configuration Manager is not a contract");
_configurationManager = IConfigurationManager(configurationManager);
constructor(IConfigurationManager _configurationManager) public {
require(
Address.isContract(address(_configurationManager)),
"OptionAMMFactory: Configuration Manager is not a contract"
);
configurationManager = _configurationManager;
}

/**
Expand All @@ -52,7 +55,7 @@ contract OptionAMMFactory is IOptionAMMFactory {
_initialSigma,
address(feePoolTokenA),
address(feePoolTokenB),
_configurationManager
configurationManager
);

address poolAddress = address(pool);
Expand Down
6 changes: 3 additions & 3 deletions contracts/amm/OptionAMMPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ contract OptionAMMPool is AMM, IOptionAMMPool, CappedPool, FlashloanProtection {
/**
* @notice store globally accessed configurations
*/
IConfigurationManager public configurationManager;
IConfigurationManager public immutable configurationManager;

/**
* @notice responsible for handling Liquidity providers fees of the token A
*/
IFeePool public feePoolA;
IFeePool public immutable feePoolA;

/**
* @notice responsible for handling Liquidity providers fees of the token B
*/
IFeePool public feePoolB;
IFeePool public immutable feePoolB;

// Option Info
struct PriceProperties {
Expand Down
13 changes: 8 additions & 5 deletions contracts/helpers/OptionHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ contract OptionHelper {
/**
* @dev store globally accessed configurations
*/
IConfigurationManager private _configurationManager;
IConfigurationManager public immutable configurationManager;

event OptionsBought(
address indexed buyer,
Expand Down Expand Up @@ -58,9 +58,12 @@ contract OptionHelper {
uint256 tokenAmount
);

constructor(address configurationManager) public {
require(Address.isContract(configurationManager), "OptionHelper: Configuration Manager is not a contract");
_configurationManager = IConfigurationManager(configurationManager);
constructor(IConfigurationManager _configurationManager) public {
require(
Address.isContract(address(_configurationManager)),
"OptionHelper: Configuration Manager is not a contract"
);
configurationManager = _configurationManager;
}

modifier withinDeadline(uint256 deadline) {
Expand Down Expand Up @@ -337,7 +340,7 @@ contract OptionHelper {
* @return IOptionAMMPool
*/
function _getPool(IPodOption option) internal view returns (IOptionAMMPool) {
IOptionAMMFactory factory = IOptionAMMFactory(_configurationManager.getAMMFactory());
IOptionAMMFactory factory = IOptionAMMFactory(configurationManager.getAMMFactory());
address exchangeOptionAddress = factory.getPool(address(option));
require(exchangeOptionAddress != address(0), "OptionHelper: pool not found");
return IOptionAMMPool(exchangeOptionAddress);
Expand Down
2 changes: 1 addition & 1 deletion contracts/options/OptionFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import "../interfaces/IPodOption.sol";
* @dev Uses IOptionBuilder to create the different types of Options
*/
contract OptionFactory {
IConfigurationManager public configurationManager;
IConfigurationManager public immutable configurationManager;
IOptionBuilder public podPutBuilder;
IOptionBuilder public wPodPutBuilder;
IOptionBuilder public podCallBuilder;
Expand Down
8 changes: 4 additions & 4 deletions contracts/options/PodOption.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ abstract contract PodOption is IPodOption, ERC20, RequiredDecimals, CappedOption

OptionType private immutable _optionType;
ExerciseType private immutable _exerciseType;
IConfigurationManager private immutable _configurationManager;
IConfigurationManager public immutable configurationManager;

address private immutable _underlyingAsset;
address private immutable _strikeAsset;
Expand Down Expand Up @@ -74,8 +74,8 @@ abstract contract PodOption is IPodOption, ERC20, RequiredDecimals, CappedOption
uint256 strikePrice,
uint256 expiration,
uint256 exerciseWindowSize,
IConfigurationManager configurationManager
) public ERC20(name, symbol) CappedOption(configurationManager) {
IConfigurationManager _configurationManager
) public ERC20(name, symbol) CappedOption(_configurationManager) {
require(Address.isContract(underlyingAsset), "PodOption: underlying asset is not a contract");
require(Address.isContract(strikeAsset), "PodOption: strike asset is not a contract");
require(underlyingAsset != strikeAsset, "PodOption: underlying asset and strike asset must differ");
Expand All @@ -93,7 +93,7 @@ abstract contract PodOption is IPodOption, ERC20, RequiredDecimals, CappedOption
_startOfExerciseWindow = block.timestamp;
}

_configurationManager = configurationManager;
configurationManager = _configurationManager;

_optionType = optionType;
_exerciseType = exerciseType;
Expand Down

0 comments on commit a6876fa

Please sign in to comment.