Skip to content

Commit

Permalink
Fixes on interfaces (#313)
Browse files Browse the repository at this point in the history
* Added OptionHelper interface

* Allowing future version usage

* Added missing SPDX
  • Loading branch information
ggviana authored Nov 25, 2021
1 parent 1dd7bfe commit b18a21f
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 13 deletions.
1 change: 1 addition & 0 deletions contracts/configuration/OptionPoolRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.8.4;

import "../interfaces/IConfigurationManager.sol";
Expand Down
25 changes: 15 additions & 10 deletions contracts/helpers/OptionHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ import "../interfaces/IConfigurationManager.sol";
import "../interfaces/IPodOption.sol";
import "../interfaces/IOptionAMMPool.sol";
import "../interfaces/IOptionPoolRegistry.sol";
import "../interfaces/IOptionHelper.sol";

/**
* @title PodOption
* @author Pods Finance
* @notice Represents a Proxy that can perform a set of operations on the behalf of an user
*/
contract OptionHelper is ReentrancyGuard {
contract OptionHelper is IOptionHelper, ReentrancyGuard {
using SafeERC20 for IERC20;
using SafeMath for uint256;

Expand Down Expand Up @@ -79,7 +80,7 @@ contract OptionHelper is ReentrancyGuard {
* @param option The option contract to mint
* @param optionAmount Amount of options to mint
*/
function mint(IPodOption option, uint256 optionAmount) external {
function mint(IPodOption option, uint256 optionAmount) external override {
_mint(option, optionAmount);

// Transfers back the minted options
Expand All @@ -102,7 +103,7 @@ contract OptionHelper is ReentrancyGuard {
uint256 minTokenAmount,
uint256 deadline,
uint256 initialIVGuess
) external nonReentrant withinDeadline(deadline) {
) external override nonReentrant withinDeadline(deadline) {
IOptionAMMPool pool = _getPool(option);

_mint(option, optionAmount);
Expand All @@ -128,7 +129,7 @@ contract OptionHelper is ReentrancyGuard {
IPodOption option,
uint256 optionAmount,
uint256 tokenAmount
) external nonReentrant {
) external override nonReentrant {
IOptionAMMPool pool = _getPool(option);
IERC20 tokenB = IERC20(pool.tokenB());

Expand Down Expand Up @@ -156,7 +157,11 @@ contract OptionHelper is ReentrancyGuard {
* @param option The option contract to mint
* @param collateralAmount Amount of collateral tokens to be used to both mint and mint into the stable side
*/
function mintAndAddLiquidityWithCollateral(IPodOption option, uint256 collateralAmount) external nonReentrant {
function mintAndAddLiquidityWithCollateral(IPodOption option, uint256 collateralAmount)
external
override
nonReentrant
{
require(option.optionType() == IPodOption.OptionType.PUT, "OptionHelper: Invalid option type");
IOptionAMMPool pool = _getPool(option);
IERC20 tokenB = IERC20(pool.tokenB());
Expand Down Expand Up @@ -189,7 +194,7 @@ contract OptionHelper is ReentrancyGuard {
IPodOption option,
uint256 optionAmount,
uint256 tokenAmount
) external nonReentrant {
) external override nonReentrant {
IOptionAMMPool pool = _getPool(option);
IERC20 tokenB = IERC20(pool.tokenB());

Expand Down Expand Up @@ -229,7 +234,7 @@ contract OptionHelper is ReentrancyGuard {
uint256 minTokenReceived,
uint256 deadline,
uint256 initialIVGuess
) external withinDeadline(deadline) nonReentrant {
) external override withinDeadline(deadline) nonReentrant {
IOptionAMMPool pool = _getPool(option);
IERC20 tokenA = IERC20(pool.tokenA());

Expand Down Expand Up @@ -261,7 +266,7 @@ contract OptionHelper is ReentrancyGuard {
uint256 exactTokenReceived,
uint256 deadline,
uint256 initialIVGuess
) external withinDeadline(deadline) nonReentrant {
) external override withinDeadline(deadline) nonReentrant {
IOptionAMMPool pool = _getPool(option);
IERC20 tokenA = IERC20(pool.tokenA());

Expand Down Expand Up @@ -303,7 +308,7 @@ contract OptionHelper is ReentrancyGuard {
uint256 maxTokenAmount,
uint256 deadline,
uint256 initialIVGuess
) external withinDeadline(deadline) nonReentrant {
) external override withinDeadline(deadline) nonReentrant {
IOptionAMMPool pool = _getPool(option);
IERC20 tokenB = IERC20(pool.tokenB());

Expand Down Expand Up @@ -344,7 +349,7 @@ contract OptionHelper is ReentrancyGuard {
uint256 tokenAmount,
uint256 deadline,
uint256 initialIVGuess
) external withinDeadline(deadline) nonReentrant {
) external override withinDeadline(deadline) nonReentrant {
IOptionAMMPool pool = _getPool(option);
IERC20 tokenB = IERC20(pool.tokenB());

Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/IAMM.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: agpl-3.0

pragma solidity 0.6.12;
pragma solidity >=0.6.12;

interface IAMM {
function addLiquidity(
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/IOptionAMMPool.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: agpl-3.0

pragma solidity 0.6.12;
pragma solidity >=0.6.12;

import "./IAMM.sol";

Expand Down
62 changes: 62 additions & 0 deletions contracts/interfaces/IOptionHelper.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// SPDX-License-Identifier: agpl-3.0
pragma solidity >=0.6.12;

import "./IPodOption.sol";

interface IOptionHelper {
function mint(IPodOption option, uint256 optionAmount) external;

function mintAndSellOptions(
IPodOption option,
uint256 optionAmount,
uint256 minTokenAmount,
uint256 deadline,
uint256 initialIVGuess
) external;

function mintAndAddLiquidity(
IPodOption option,
uint256 optionAmount,
uint256 tokenAmount
) external;

function mintAndAddLiquidityWithCollateral(IPodOption option, uint256 collateralAmount) external;

function addLiquidity(
IPodOption option,
uint256 optionAmount,
uint256 tokenAmount
) external;

function sellExactOptions(
IPodOption option,
uint256 optionAmount,
uint256 minTokenReceived,
uint256 deadline,
uint256 initialIVGuess
) external;

function sellOptionsAndReceiveExactTokens(
IPodOption option,
uint256 maxOptionAmount,
uint256 exactTokenReceived,
uint256 deadline,
uint256 initialIVGuess
) external;

function buyExactOptions(
IPodOption option,
uint256 optionAmount,
uint256 maxTokenAmount,
uint256 deadline,
uint256 initialIVGuess
) external;

function buyOptionsWithExactTokens(
IPodOption option,
uint256 minOptionAmount,
uint256 tokenAmount,
uint256 deadline,
uint256 initialIVGuess
) external;
}
1 change: 1 addition & 0 deletions contracts/interfaces/IOptionPoolRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: agpl-3.0
pragma solidity >=0.6.12;

interface IOptionPoolRegistry {
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/IPodOption.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: agpl-3.0

pragma solidity 0.6.12;
pragma solidity >=0.6.12;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

Expand Down

0 comments on commit b18a21f

Please sign in to comment.