Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OptionsCompounder #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions src/OptionsCompounder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ contract OptionsCompounder is IFlashLoanReceiver, OwnableUpgradeable, UUPSUpgrad
uint256 public constant FUTURE_NEXT_PROPOSAL_TIME = 365 days * 100;

/* Storages */
address public swapper;
ILendingPoolAddressesProvider private addressProvider;
ILendingPool private lendingPool;
bool private flashloanFinished;
Expand Down Expand Up @@ -84,7 +83,6 @@ contract OptionsCompounder is IFlashLoanReceiver, OwnableUpgradeable, UUPSUpgrad
function initialize(
address _optionsToken,
address _addressProvider,
address _swapper,
SwapProps memory _swapProps,
IOracle _oracle,
address[] memory _strats
Expand All @@ -93,7 +91,6 @@ contract OptionsCompounder is IFlashLoanReceiver, OwnableUpgradeable, UUPSUpgrad
_setOptionsToken(_optionsToken);
_setSwapProps(_swapProps);
_setOracle(_oracle);
_setSwapper(_swapper);
_setStrats(_strats);
flashloanFinished = true;
_setAddressProvider(_addressProvider);
Expand Down Expand Up @@ -135,17 +132,6 @@ contract OptionsCompounder is IFlashLoanReceiver, OwnableUpgradeable, UUPSUpgrad
oracle = _oracle;
}

function setSwapper(address _swapper) external onlyOwner {
_setSwapper(_swapper);
}

function _setSwapper(address _swapper) internal {
if (_swapper == address(0)) {
revert OptionsCompounder__ParamHasAddressZero();
}
swapper = _swapper;
}

function setAddressProvider(address _addressProvider) external onlyOwner {
_setAddressProvider(_addressProvider);
}
Expand Down Expand Up @@ -325,7 +311,7 @@ contract OptionsCompounder is IFlashLoanReceiver, OwnableUpgradeable, UUPSUpgrad
minAmountOut = _getMinAmountOutData(balanceOfUnderlyingToken, swapProps.maxSwapSlippage, address(oracle));

/* Approve the underlying token to make swap */
underlyingToken.approve(swapper, balanceOfUnderlyingToken);
underlyingToken.approve(swapProps.swapper, balanceOfUnderlyingToken);

/* Swap underlying token to payment token (asset) */
swapAmountOut = _generalSwap(
Expand All @@ -337,7 +323,7 @@ contract OptionsCompounder is IFlashLoanReceiver, OwnableUpgradeable, UUPSUpgrad
}

/* Approve the underlying token to 0 for safety */
underlyingToken.approve(swapper, 0);
underlyingToken.approve(swapProps.swapper, 0);
}

/* Calculate profit and revert if it is not profitable */
Expand Down
2 changes: 1 addition & 1 deletion test/ItMode_OptionsCompounder.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ contract ItModeOptionsCompounder is Common {
tmpProxy = new ERC1967Proxy(address(optionsCompounder), "");
optionsCompounder = OptionsCompounder(address(tmpProxy));
console.log("Initializing...");
optionsCompounder.initialize(address(optionsTokenProxy), address(addressProvider), address(reaperSwapper), swapProps, oracle, strategies);
optionsCompounder.initialize(address(optionsTokenProxy), address(addressProvider), swapProps, oracle, strategies);

vm.stopPrank();

Expand Down