diff --git a/contracts/BIFI/infra/BeefyRewardPool.sol b/contracts/BIFI/infra/BeefyRewardPool.txt similarity index 100% rename from contracts/BIFI/infra/BeefyRewardPool.sol rename to contracts/BIFI/infra/BeefyRewardPool.txt diff --git a/contracts/BIFI/infra/BeefyStrategyMulticall.sol b/contracts/BIFI/infra/BeefyStrategyMulticall.sol index cde168ed..65ef306a 100644 --- a/contracts/BIFI/infra/BeefyStrategyMulticall.sol +++ b/contracts/BIFI/infra/BeefyStrategyMulticall.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.6.12; +pragma solidity ^0.8.0; import "../interfaces/beefy/IVault.sol"; diff --git a/contracts/BIFI/infra/BeefyTreasury.sol b/contracts/BIFI/infra/BeefyTreasury.sol index 68442625..3cfb5b91 100644 --- a/contracts/BIFI/infra/BeefyTreasury.sol +++ b/contracts/BIFI/infra/BeefyTreasury.sol @@ -1,10 +1,10 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.6.12; +pragma solidity ^0.8.0; -import "@openzeppelin/contracts/access/Ownable.sol"; -import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; -import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; +import "@openzeppelin-4/contracts/access/Ownable.sol"; +import "@openzeppelin-4/contracts/token/ERC20/ERC20.sol"; +import "@openzeppelin-4/contracts/token/ERC20/utils/SafeERC20.sol"; contract BeefyTreasury is Ownable { using SafeERC20 for IERC20; diff --git a/contracts/BIFI/interfaces/beamswap/IBeamChef.sol b/contracts/BIFI/interfaces/beamswap/IBeamChef.sol index fb695196..33f13e0e 100644 --- a/contracts/BIFI/interfaces/beamswap/IBeamChef.sol +++ b/contracts/BIFI/interfaces/beamswap/IBeamChef.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.6.0; +pragma solidity ^0.8.0; interface IBeamChef { function deposit(uint256 _pid, uint256 _amount) external; diff --git a/contracts/BIFI/interfaces/beefy/IStrategy.sol b/contracts/BIFI/interfaces/beefy/IStrategy.sol index c5d6e9f3..a7f2c1e9 100644 --- a/contracts/BIFI/interfaces/beefy/IStrategy.sol +++ b/contracts/BIFI/interfaces/beefy/IStrategy.sol @@ -2,7 +2,7 @@ pragma solidity >=0.6.0 <0.9.0; -import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import "@openzeppelin-4/contracts/token/ERC20/IERC20.sol"; interface IStrategy { function vault() external view returns (address); diff --git a/contracts/BIFI/interfaces/beefy/IStrategyComplete.sol b/contracts/BIFI/interfaces/beefy/IStrategyComplete.sol index e0236998..e5e7671e 100644 --- a/contracts/BIFI/interfaces/beefy/IStrategyComplete.sol +++ b/contracts/BIFI/interfaces/beefy/IStrategyComplete.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.6.0; +pragma solidity ^0.8.0; -import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import "@openzeppelin-4/contracts/token/ERC20/IERC20.sol"; interface IStrategyComplete { function vault() external view returns (address); diff --git a/contracts/BIFI/interfaces/beefy/IVault.sol b/contracts/BIFI/interfaces/beefy/IVault.sol index 1acddbf2..403a42b1 100644 --- a/contracts/BIFI/interfaces/beefy/IVault.sol +++ b/contracts/BIFI/interfaces/beefy/IVault.sol @@ -2,7 +2,7 @@ pragma solidity >=0.6.0 <0.9.0; -import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import "@openzeppelin-4/contracts/token/ERC20/IERC20.sol"; import "./IStrategy.sol"; interface IVault is IERC20 { diff --git a/contracts/BIFI/interfaces/common/IComptroller.sol b/contracts/BIFI/interfaces/common/IComptroller.sol index 1a5bc292..81b083a4 100644 --- a/contracts/BIFI/interfaces/common/IComptroller.sol +++ b/contracts/BIFI/interfaces/common/IComptroller.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.6.0; +pragma solidity ^0.8.0; interface IComptroller { function claimComp(address holder, address[] calldata _iTokens) external; diff --git a/contracts/BIFI/interfaces/common/IERC20Extended.sol b/contracts/BIFI/interfaces/common/IERC20Extended.sol index 43c3ae11..d0442443 100644 --- a/contracts/BIFI/interfaces/common/IERC20Extended.sol +++ b/contracts/BIFI/interfaces/common/IERC20Extended.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0 <0.9.0; +pragma solidity ^0.8.0; interface IERC20Extended { function symbol() external view returns (string memory); diff --git a/contracts/BIFI/interfaces/common/IUniswapRouterV3WithDeadline.sol b/contracts/BIFI/interfaces/common/IUniswapRouterV3WithDeadline.sol index cf3133b3..3d64b393 100644 --- a/contracts/BIFI/interfaces/common/IUniswapRouterV3WithDeadline.sol +++ b/contracts/BIFI/interfaces/common/IUniswapRouterV3WithDeadline.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0; -pragma experimental ABIEncoderV2; +pragma solidity ^0.8.0; + interface IUniswapRouterV3WithDeadline { struct ExactInputSingleParams { diff --git a/contracts/BIFI/interfaces/common/IVToken.sol b/contracts/BIFI/interfaces/common/IVToken.sol index 8fd05aec..c0ba0447 100644 --- a/contracts/BIFI/interfaces/common/IVToken.sol +++ b/contracts/BIFI/interfaces/common/IVToken.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.6.0; +pragma solidity ^0.8.0; -import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; +import "@openzeppelin-4/contracts/token/ERC20/ERC20.sol"; interface IVToken is IERC20 { function underlying() external returns (address); diff --git a/contracts/BIFI/interfaces/common/IxWant.sol b/contracts/BIFI/interfaces/common/IxWant.sol index e03ef7c8..63d70e22 100644 --- a/contracts/BIFI/interfaces/common/IxWant.sol +++ b/contracts/BIFI/interfaces/common/IxWant.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.6.12; +pragma solidity ^0.8.0; interface IxWant { function enter(uint256 _amount) external; diff --git a/contracts/BIFI/interfaces/kyber/IDMMRouter.sol b/contracts/BIFI/interfaces/kyber/IDMMRouter.sol index 5fa8f436..a823af80 100644 --- a/contracts/BIFI/interfaces/kyber/IDMMRouter.sol +++ b/contracts/BIFI/interfaces/kyber/IDMMRouter.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >0.6.0; +pragma solidity >0.8.0; import "@openzeppelin-4/contracts/token/ERC20/ERC20.sol"; diff --git a/contracts/BIFI/interfaces/mai/IFarm.sol b/contracts/BIFI/interfaces/mai/IFarm.sol index 667e2ced..7f1d3ca8 100644 --- a/contracts/BIFI/interfaces/mai/IFarm.sol +++ b/contracts/BIFI/interfaces/mai/IFarm.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.6.0; +pragma solidity ^0.8.0; interface IFarm { function deposit(uint256 _pid, uint256 _amount) external; diff --git a/contracts/BIFI/interfaces/pancake/IMasterChef.sol b/contracts/BIFI/interfaces/pancake/IMasterChef.sol index debf0639..154634b6 100644 --- a/contracts/BIFI/interfaces/pancake/IMasterChef.sol +++ b/contracts/BIFI/interfaces/pancake/IMasterChef.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.6.0; +pragma solidity ^0.8.0; interface IMasterChef { function deposit(uint256 _pid, uint256 _amount) external; diff --git a/contracts/BIFI/interfaces/pancake/ISmartChef.sol b/contracts/BIFI/interfaces/pancake/ISmartChef.sol index 6865bbc7..9610b8f2 100644 --- a/contracts/BIFI/interfaces/pancake/ISmartChef.sol +++ b/contracts/BIFI/interfaces/pancake/ISmartChef.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.6.0; +pragma solidity ^0.8.0; interface ISmartChef { function deposit(uint256 _amount) external; diff --git a/contracts/BIFI/interfaces/pancake/IVeCakeStaker.sol b/contracts/BIFI/interfaces/pancake/IVeCakeStaker.sol index 4b92fe00..86802538 100644 --- a/contracts/BIFI/interfaces/pancake/IVeCakeStaker.sol +++ b/contracts/BIFI/interfaces/pancake/IVeCakeStaker.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.6.0; +pragma solidity ^0.8.0; interface IVeCakeStaker { function deposit(address _chef, uint256 _pid, uint256 _amount) external; diff --git a/contracts/BIFI/interfaces/spooky/ISpookyChefV2.sol b/contracts/BIFI/interfaces/spooky/ISpookyChefV2.sol index 4b73674b..54d74278 100644 --- a/contracts/BIFI/interfaces/spooky/ISpookyChefV2.sol +++ b/contracts/BIFI/interfaces/spooky/ISpookyChefV2.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.6.0; +pragma solidity ^0.8.0; interface ISpookyChefV2 { function deposit(uint256 _pid, uint256 _amount) external; diff --git a/contracts/BIFI/interfaces/spooky/ISpookyRewarder.sol b/contracts/BIFI/interfaces/spooky/ISpookyRewarder.sol index 1c3f6e16..05ad03ab 100644 --- a/contracts/BIFI/interfaces/spooky/ISpookyRewarder.sol +++ b/contracts/BIFI/interfaces/spooky/ISpookyRewarder.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.6.0; +pragma solidity ^0.8.0; interface ISpookyRewarder { function pendingToken(uint _pid, address _user) external view returns (uint pending); diff --git a/contracts/BIFI/interfaces/spooky/IXChef.sol b/contracts/BIFI/interfaces/spooky/IXChef.sol index 9213c815..ecc3ef11 100644 --- a/contracts/BIFI/interfaces/spooky/IXChef.sol +++ b/contracts/BIFI/interfaces/spooky/IXChef.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0; +pragma solidity >=0.8.0; interface IXChef { function deposit(uint256 pid, uint256 amount) external; diff --git a/contracts/BIFI/interfaces/spooky/IXPool.sol b/contracts/BIFI/interfaces/spooky/IXPool.sol index 30d07d6d..ddd1f3b7 100644 --- a/contracts/BIFI/interfaces/spooky/IXPool.sol +++ b/contracts/BIFI/interfaces/spooky/IXPool.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0; +pragma solidity >=0.8.0; interface IXPool { function enter(uint256 amount) external; diff --git a/contracts/BIFI/interfaces/traderjoe/IStableJoeStaking.sol b/contracts/BIFI/interfaces/traderjoe/IStableJoeStaking.sol index 9af32283..6d362c6d 100644 --- a/contracts/BIFI/interfaces/traderjoe/IStableJoeStaking.sol +++ b/contracts/BIFI/interfaces/traderjoe/IStableJoeStaking.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.6.0; +pragma solidity ^0.8.0; interface IStableJoeStaking { function deposit(uint256 _amount) external; diff --git a/contracts/BIFI/interfaces/traderjoe/IVeJoeStaker.sol b/contracts/BIFI/interfaces/traderjoe/IVeJoeStaker.sol index 71b7b4e8..dfe02eba 100644 --- a/contracts/BIFI/interfaces/traderjoe/IVeJoeStaker.sol +++ b/contracts/BIFI/interfaces/traderjoe/IVeJoeStaker.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.6.0; +pragma solidity ^0.8.0; interface IVeJoeStaker { function deposit(address _chef, uint256 _pid, uint256 _amount) external; diff --git a/contracts/BIFI/mocks/TestToken.sol b/contracts/BIFI/mocks/TestToken.sol index 0367d51d..18f7342f 100644 --- a/contracts/BIFI/mocks/TestToken.sol +++ b/contracts/BIFI/mocks/TestToken.sol @@ -1,14 +1,14 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.6.0; +pragma solidity ^0.8.0; -import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; +import "@openzeppelin-4/contracts/token/ERC20/ERC20.sol"; contract TestToken is ERC20 { constructor( uint256 _initialSupply, string memory _name, string memory _symbol - ) public ERC20(_name, _symbol) { + ) ERC20(_name, _symbol) { _mint(msg.sender, _initialSupply); } } \ No newline at end of file diff --git a/contracts/BIFI/strategies/Aave/StrategyAave.sol b/contracts/BIFI/strategies/Aave/StrategyAave.sol deleted file mode 100644 index 7fe2b1d8..00000000 --- a/contracts/BIFI/strategies/Aave/StrategyAave.sol +++ /dev/null @@ -1,435 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity ^0.6.12; - -import "@openzeppelin/contracts/access/Ownable.sol"; -import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; -import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; -import "@openzeppelin/contracts/math/SafeMath.sol"; -import "@openzeppelin/contracts/utils/Pausable.sol"; - -import "../../interfaces/aave/IDataProvider.sol"; -import "../../interfaces/aave/IAaveV3Incentives.sol"; -import "../../interfaces/aave/ILendingPool.sol"; -import "../../interfaces/common/IUniswapRouterETH.sol"; -import "../Common/FeeManager.sol"; -import "../Common/StratManager.sol"; - -contract StrategyAave is StratManager, FeeManager { - using SafeERC20 for IERC20; - using SafeMath for uint256; - - // Tokens used - address public native; - address public want; - address public aToken; - address public varDebtToken; - - // Third party contracts - address public dataProvider; - address public lendingPool; - address public incentivesController; - - // Routes - address[] public nativeToWantRoute; - - bool public harvestOnDeposit; - uint256 public lastHarvest; - - /** - * @dev Variables that can be changed to config profitability and risk: - * {borrowRate} - What % of our collateral do we borrow per leverage level. - * {borrowRateMax} - A limit on how much we can push borrow risk. - * {borrowDepth} - How many levels of leverage do we take. - * {minLeverage} - The minimum amount of collateral required to leverage. - * {BORROW_DEPTH_MAX} - A limit on how many steps we can leverage. - * {INTEREST_RATE_MODE} - The type of borrow debt. Stable: 1, Variable: 2. - */ - uint256 public borrowRate; - uint256 public borrowRateMax; - uint256 public borrowDepth; - uint256 public minLeverage; - uint256 constant public BORROW_DEPTH_MAX = 10; - uint256 constant public INTEREST_RATE_MODE = 2; - - /** - * @dev Helps to differentiate borrowed funds that shouldn't be used in functions like 'deposit()' - * as they're required to deleverage correctly. - */ - uint256 public reserves = 0; - - /** - * @dev Events that the contract emits - */ - event StratHarvest(address indexed harvester, uint256 wantHarvested, uint256 tvl); - event Deposit(uint256 tvl); - event Withdraw(uint256 tvl); - event ChargedFees(uint256 callFees, uint256 beefyFees, uint256 strategistFees); - event StratRebalance(uint256 _borrowRate, uint256 _borrowDepth); - event SetEMode(uint8 eMode, uint256 borrowRateMax, uint256 borrowRate, uint256 borrowDepth); - - constructor( - address _want, - address _native, - uint256 _borrowRate, - uint256 _borrowRateMax, - uint256 _borrowDepth, - uint256 _minLeverage, - uint8 _eMode, - address _dataProvider, - address _lendingPool, - address _incentivesController, - address _vault, - address _unirouter, - address _keeper, - address _strategist, - address _beefyFeeRecipient - ) StratManager(_keeper, _strategist, _unirouter, _vault, _beefyFeeRecipient) public { - want = _want; - native = _native; - - borrowRate = _borrowRate; - borrowRateMax = _borrowRateMax; - borrowDepth = _borrowDepth; - minLeverage = _minLeverage; - dataProvider = _dataProvider; - lendingPool = _lendingPool; - incentivesController = _incentivesController; - - (aToken,,varDebtToken) = IDataProvider(dataProvider).getReserveTokensAddresses(want); - - if (_eMode != 0) { - ILendingPool(lendingPool).setUserEMode(_eMode); - } - - nativeToWantRoute = [native, want]; - - _giveAllowances(); - } - - // puts the funds to work - function deposit() public whenNotPaused { - uint256 wantBal = availableWant(); - - if (wantBal > 0) { - _leverage(wantBal); - emit Deposit(balanceOf()); - } - } - - /** - * @dev Repeatedly supplies and borrows {want} following the configured {borrowRate} and {borrowDepth} - * @param _amount amount of {want} to leverage - */ - function _leverage(uint256 _amount) internal { - if (_amount < minLeverage) { return; } - - for (uint i = 0; i < borrowDepth; i++) { - ILendingPool(lendingPool).deposit(want, _amount, address(this), 0); - _amount = _amount.mul(borrowRate).div(100); - if (_amount > 0) { - ILendingPool(lendingPool).borrow(want, _amount, INTEREST_RATE_MODE, 0, address(this)); - } - } - - reserves = reserves.add(_amount); - } - - /** - * @dev Incrementally alternates between paying part of the debt and withdrawing part of the supplied - * collateral. Continues to do this until it repays the entire debt and withdraws all the supplied {want} - * from the system - */ - function _deleverage() internal { - uint256 wantBal = balanceOfWant(); - (uint256 supplyBal, uint256 borrowBal) = userReserves(); - - while (wantBal < borrowBal) { - ILendingPool(lendingPool).repay(want, wantBal, INTEREST_RATE_MODE, address(this)); - - (supplyBal, borrowBal) = userReserves(); - uint256 targetSupply = borrowBal.mul(100).div(borrowRate); - - ILendingPool(lendingPool).withdraw(want, supplyBal.sub(targetSupply), address(this)); - wantBal = balanceOfWant(); - } - - if (borrowBal > 0) { - ILendingPool(lendingPool).repay(want, uint256(-1), INTEREST_RATE_MODE, address(this)); - } - if (supplyBal > 0) { - ILendingPool(lendingPool).withdraw(want, type(uint).max, address(this)); - } - - reserves = 0; - } - - /** - * @dev Extra safety measure that allows us to manually unwind one level. In case we somehow get into - * as state where the cost of unwinding freezes the system. We can manually unwind a few levels - * with this function and then 'rebalance()' with new {borrowRate} and {borrowConfig} values. - * @param _borrowRate configurable borrow rate in case it's required to unwind successfully - */ - function deleverageOnce(uint _borrowRate) external onlyManager { - require(_borrowRate <= borrowRateMax, "!safe"); - - uint256 wantBal = balanceOfWant(); - if (wantBal > 0) { - ILendingPool(lendingPool).repay(want, wantBal, INTEREST_RATE_MODE, address(this)); - } - - (uint256 supplyBal, uint256 borrowBal) = userReserves(); - uint256 targetSupply = borrowBal.mul(100).div(_borrowRate); - - if (supplyBal.sub(targetSupply) > 0) { - ILendingPool(lendingPool).withdraw(want, supplyBal.sub(targetSupply), address(this)); - } - - reserves = balanceOfWant(); - } - - /** - * @dev Updates the risk profile and rebalances the vault funds accordingly. - * @param _borrowRate percent to borrow on each leverage level. - * @param _borrowDepth how many levels to leverage the funds. - */ - function rebalance(uint256 _borrowRate, uint256 _borrowDepth) external onlyManager { - require(_borrowRate <= borrowRateMax, "!rate"); - require(_borrowDepth <= BORROW_DEPTH_MAX, "!depth"); - - _deleverage(); - borrowRate = _borrowRate; - borrowDepth = _borrowDepth; - - uint256 wantBal = balanceOfWant(); - _leverage(wantBal); - - emit StratRebalance(_borrowRate, _borrowDepth); - } - - function beforeDeposit() external override { - if (harvestOnDeposit) { - require(msg.sender == vault, "!vault"); - _harvest(tx.origin); - } - } - - function harvest() external virtual { - _harvest(tx.origin); - } - - function harvest(address callFeeRecipient) external virtual { - _harvest(callFeeRecipient); - } - - function managerHarvest() external onlyManager { - _harvest(tx.origin); - } - - // compounds earnings and charges performance fee - function _harvest(address callFeeRecipient) internal whenNotPaused { - address[] memory assets = new address[](2); - assets[0] = aToken; - assets[1] = varDebtToken; - IAaveV3Incentives(incentivesController).claimRewards(assets, type(uint).max, address(this), native); - - uint256 nativeBal = IERC20(native).balanceOf(address(this)); - if (nativeBal > 0) { - chargeFees(callFeeRecipient); - swapRewards(); - uint256 wantHarvested = availableWant(); - deposit(); - - lastHarvest = block.timestamp; - emit StratHarvest(msg.sender, wantHarvested, balanceOf()); - } - } - - // performance fees - function chargeFees(address callFeeRecipient) internal { - uint256 nativeFeeBal = IERC20(native).balanceOf(address(this)).mul(45).div(1000); - - uint256 callFeeAmount = nativeFeeBal.mul(callFee).div(MAX_FEE); - IERC20(native).safeTransfer(callFeeRecipient, callFeeAmount); - - uint256 beefyFeeAmount = nativeFeeBal.mul(beefyFee).div(MAX_FEE); - IERC20(native).safeTransfer(beefyFeeRecipient, beefyFeeAmount); - - uint256 strategistFeeAmount = nativeFeeBal.mul(STRATEGIST_FEE).div(MAX_FEE); - IERC20(native).safeTransfer(strategist, strategistFeeAmount); - - emit ChargedFees(callFeeAmount, beefyFeeAmount, strategistFeeAmount); - } - - // swap rewards to {want} - function swapRewards() internal { - uint256 nativeBal = IERC20(native).balanceOf(address(this)); - IUniswapRouterETH(unirouter).swapExactTokensForTokens(nativeBal, 0, nativeToWantRoute, address(this), now); - } - - /** - * @dev Withdraws funds and sends them back to the vault. It deleverages from venus first, - * and then deposits again after the withdraw to make sure it mantains the desired ratio. - * @param _amount How much {want} to withdraw. - */ - function withdraw(uint256 _amount) external { - require(msg.sender == vault, "!vault"); - - uint256 wantBal = availableWant(); - if (wantBal < _amount) { - _deleverage(); - wantBal = balanceOfWant(); - } - - if (wantBal > _amount) { - wantBal = _amount; - } - - if (tx.origin != owner() && !paused()) { - uint256 withdrawalFeeAmount = wantBal.mul(withdrawalFee).div(WITHDRAWAL_MAX); - wantBal = wantBal.sub(withdrawalFeeAmount); - } - - IERC20(want).safeTransfer(vault, wantBal); - emit Withdraw(balanceOf()); - - if (!paused()) { - _leverage(availableWant()); - } - } - - /** - * @dev Required for various functions that need to deduct {reserves} from total {want}. - * @return how much {want} the contract holds without reserves - */ - function availableWant() public view returns (uint256) { - return balanceOfWant().sub(reserves); - } - - // return supply and borrow balance - function userReserves() public view returns (uint256, uint256) { - (uint256 supplyBal,,uint256 borrowBal,,,,,,) = IDataProvider(dataProvider).getUserReserveData(want, address(this)); - return (supplyBal, borrowBal); - } - - // returns the user account data across all the reserves - function userAccountData() public view returns ( - uint256 totalCollateralETH, - uint256 totalDebtETH, - uint256 availableBorrowsETH, - uint256 currentLiquidationThreshold, - uint256 ltv, - uint256 healthFactor - ) { - return ILendingPool(lendingPool).getUserAccountData(address(this)); - } - - // calculate the total underlaying 'want' held by the strat. - function balanceOf() public view returns (uint256) { - return balanceOfWant().add(balanceOfPool()); - } - - // it calculates how much 'want' this contract holds. - function balanceOfWant() public view returns (uint256) { - return IERC20(want).balanceOf(address(this)); - } - - // it calculates how much 'want' the strategy has working in the farm. - function balanceOfPool() public view returns (uint256) { - (uint256 supplyBal, uint256 borrowBal) = userReserves(); - return supplyBal.sub(borrowBal); - } - - function nativeToWant() public view returns (address[] memory) { - return nativeToWantRoute; - } - - // returns rewards unharvested - function rewardsAvailable() public view returns (uint256) { - address[] memory assets = new address[](2); - assets[0] = aToken; - assets[1] = varDebtToken; - return IAaveV3Incentives(incentivesController).getUserRewards(assets, address(this), native); - } - - // native reward amount for calling harvest - function callReward() public view returns (uint256) { - return rewardsAvailable().mul(45).div(1000).mul(callFee).div(MAX_FEE); - } - - // returns strategy's eMode - function eMode() external view returns (uint256) { - return ILendingPool(lendingPool).getUserEMode(address(this)); - } - - // set strategy to a new eMode and set borrowRateMax to the loan-to-value of the new eMode category - function setEMode(uint8 _eMode, uint256 _borrowRateMax, uint256 _borrowRate, uint256 _borrowDepth) external onlyManager { - _deleverage(); - ILendingPool(lendingPool).setUserEMode(_eMode); - - if (_eMode != 0) { - (uint16 ltv,,,,) = ILendingPool(lendingPool).getEModeCategoryData(_eMode); - borrowRateMax = uint256(ltv).div(100); - } else { - borrowRateMax = _borrowRateMax; - } - - require(_borrowRate <= borrowRateMax, "!rate"); - require(_borrowDepth <= BORROW_DEPTH_MAX, "!depth"); - borrowRate = _borrowRate; - borrowDepth = _borrowDepth; - - _leverage(balanceOfWant()); - - emit SetEMode(_eMode, borrowRateMax, borrowRate, borrowDepth); - } - - function setHarvestOnDeposit(bool _harvestOnDeposit) external onlyManager { - harvestOnDeposit = _harvestOnDeposit; - if (harvestOnDeposit) { - setWithdrawalFee(0); - } else { - setWithdrawalFee(10); - } - } - - // called as part of strat migration. Sends all the available funds back to the vault. - function retireStrat() external { - require(msg.sender == vault, "!vault"); - - _deleverage(); - - uint256 wantBal = balanceOfWant(); - IERC20(want).transfer(vault, wantBal); - } - - // pauses deposits and withdraws all funds from third party systems. - function panic() public onlyManager { - _deleverage(); - pause(); - } - - function pause() public onlyManager { - _pause(); - - _removeAllowances(); - } - - function unpause() external onlyManager { - _unpause(); - - _giveAllowances(); - - deposit(); - } - - function _giveAllowances() internal { - IERC20(want).safeApprove(lendingPool, uint256(-1)); - IERC20(native).safeApprove(unirouter, uint256(-1)); - } - - function _removeAllowances() internal { - IERC20(want).safeApprove(lendingPool, 0); - IERC20(native).safeApprove(unirouter, 0); - } -} \ No newline at end of file diff --git a/contracts/BIFI/strategies/Aave/StrategyAaveSupplyOnly.sol b/contracts/BIFI/strategies/Aave/StrategyAaveSupplyOnly.sol deleted file mode 100644 index b88fec91..00000000 --- a/contracts/BIFI/strategies/Aave/StrategyAaveSupplyOnly.sol +++ /dev/null @@ -1,258 +0,0 @@ -// SPDX-License-Identifier: MIT - -pragma solidity ^0.6.12; - -import "@openzeppelin/contracts/access/Ownable.sol"; -import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; -import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; -import "@openzeppelin/contracts/math/SafeMath.sol"; -import "@openzeppelin/contracts/utils/Pausable.sol"; - -import "../../interfaces/aave/IDataProvider.sol"; -import "../../interfaces/aave/IAaveV3Incentives.sol"; -import "../../interfaces/aave/ILendingPool.sol"; -import "../../interfaces/common/IUniswapRouterETH.sol"; -import "../Common/FeeManager.sol"; -import "../Common/StratManager.sol"; - -contract StrategyAaveSupplyOnly is StratManager, FeeManager { - using SafeERC20 for IERC20; - using SafeMath for uint256; - - // Tokens used - address public native; - address public want; - address public aToken; - - // Third party contracts - address public dataProvider; - address public lendingPool; - address public incentivesController; - - // Routes - address[] public nativeToWantRoute; - - bool public harvestOnDeposit; - uint256 public lastHarvest; - - event StratHarvest(address indexed harvester, uint256 wantHarvested, uint256 tvl); - event Deposit(uint256 tvl); - event Withdraw(uint256 tvl); - event ChargedFees(uint256 callFees, uint256 beefyFees, uint256 strategistFees); - - constructor( - address _want, - address _native, - address _dataProvider, - address _lendingPool, - address _incentivesController, - address _vault, - address _unirouter, - address _keeper, - address _strategist, - address _beefyFeeRecipient - ) StratManager(_keeper, _strategist, _unirouter, _vault, _beefyFeeRecipient) public { - want = _want; - native = _native; - - dataProvider = _dataProvider; - lendingPool = _lendingPool; - incentivesController = _incentivesController; - - (aToken,,) = IDataProvider(dataProvider).getReserveTokensAddresses(want); - - nativeToWantRoute = [native, want]; - - _giveAllowances(); - } - - // puts the funds to work - function deposit() public whenNotPaused { - uint256 wantBal = balanceOfWant(); - - if (wantBal > 0) { - ILendingPool(lendingPool).deposit(want, wantBal, address(this), 0); - emit Deposit(balanceOf()); - } - } - - function withdraw(uint256 _amount) external { - require(msg.sender == vault, "!vault"); - - uint256 wantBal = balanceOfWant(); - if (wantBal < _amount) { - ILendingPool(lendingPool).withdraw(want, _amount.sub(wantBal), address(this)); - wantBal = balanceOfWant(); - } - - if (wantBal > _amount) { - wantBal = _amount; - } - - if (tx.origin != owner() && !paused()) { - uint256 withdrawalFeeAmount = wantBal.mul(withdrawalFee).div(WITHDRAWAL_MAX); - wantBal = wantBal.sub(withdrawalFeeAmount); - } - - IERC20(want).safeTransfer(vault, wantBal); - emit Withdraw(balanceOf()); - } - - function beforeDeposit() external override { - if (harvestOnDeposit) { - require(msg.sender == vault, "!vault"); - _harvest(tx.origin); - } - } - - function harvest() external virtual { - _harvest(tx.origin); - } - - function harvest(address callFeeRecipient) external virtual { - _harvest(callFeeRecipient); - } - - function managerHarvest() external onlyManager { - _harvest(tx.origin); - } - - // compounds earnings and charges performance fee - function _harvest(address callFeeRecipient) internal whenNotPaused { - address[] memory assets = new address[](1); - assets[0] = aToken; - IAaveV3Incentives(incentivesController).claimRewards(assets, type(uint).max, address(this), native); - - uint256 nativeBal = IERC20(native).balanceOf(address(this)); - if (nativeBal > 0) { - chargeFees(callFeeRecipient); - swapRewards(); - uint256 wantHarvested = balanceOfWant(); - deposit(); - - lastHarvest = block.timestamp; - emit StratHarvest(msg.sender, wantHarvested, balanceOf()); - } - } - - // performance fees - function chargeFees(address callFeeRecipient) internal { - uint256 nativeFeeBal = IERC20(native).balanceOf(address(this)).mul(45).div(1000); - - uint256 callFeeAmount = nativeFeeBal.mul(callFee).div(MAX_FEE); - IERC20(native).safeTransfer(callFeeRecipient, callFeeAmount); - - uint256 beefyFeeAmount = nativeFeeBal.mul(beefyFee).div(MAX_FEE); - IERC20(native).safeTransfer(beefyFeeRecipient, beefyFeeAmount); - - uint256 strategistFeeAmount = nativeFeeBal.mul(STRATEGIST_FEE).div(MAX_FEE); - IERC20(native).safeTransfer(strategist, strategistFeeAmount); - - emit ChargedFees(callFeeAmount, beefyFeeAmount, strategistFeeAmount); - } - - // swap rewards to {want} - function swapRewards() internal { - uint256 nativeBal = IERC20(native).balanceOf(address(this)); - IUniswapRouterETH(unirouter).swapExactTokensForTokens(nativeBal, 0, nativeToWantRoute, address(this), now); - } - - // return supply and borrow balance - function userReserves() public view returns (uint256, uint256) { - (uint256 supplyBal,,uint256 borrowBal,,,,,,) = IDataProvider(dataProvider).getUserReserveData(want, address(this)); - return (supplyBal, borrowBal); - } - - // returns the user account data across all the reserves - function userAccountData() public view returns ( - uint256 totalCollateralETH, - uint256 totalDebtETH, - uint256 availableBorrowsETH, - uint256 currentLiquidationThreshold, - uint256 ltv, - uint256 healthFactor - ) { - return ILendingPool(lendingPool).getUserAccountData(address(this)); - } - - // calculate the total underlaying 'want' held by the strat. - function balanceOf() public view returns (uint256) { - return balanceOfWant().add(balanceOfPool()); - } - - // it calculates how much 'want' this contract holds. - function balanceOfWant() public view returns (uint256) { - return IERC20(want).balanceOf(address(this)); - } - - // it calculates how much 'want' the strategy has working in the farm. - function balanceOfPool() public view returns (uint256) { - (uint256 supplyBal, uint256 borrowBal) = userReserves(); - return supplyBal.sub(borrowBal); - } - - function nativeToWant() public view returns (address[] memory) { - return nativeToWantRoute; - } - - // returns rewards unharvested - function rewardsAvailable() public view returns (uint256) { - address[] memory assets = new address[](1); - assets[0] = aToken; - return IAaveV3Incentives(incentivesController).getUserRewards(assets, address(this), native); - } - - // native reward amount for calling harvest - function callReward() public view returns (uint256) { - return rewardsAvailable().mul(45).div(1000).mul(callFee).div(MAX_FEE); - } - - function setHarvestOnDeposit(bool _harvestOnDeposit) external onlyManager { - harvestOnDeposit = _harvestOnDeposit; - if (harvestOnDeposit) { - setWithdrawalFee(0); - } else { - setWithdrawalFee(10); - } - } - - // called as part of strat migration. Sends all the available funds back to the vault. - function retireStrat() external { - require(msg.sender == vault, "!vault"); - - ILendingPool(lendingPool).withdraw(want, type(uint).max, address(this)); - - uint256 wantBal = balanceOfWant(); - IERC20(want).transfer(vault, wantBal); - } - - // pauses deposits and withdraws all funds from third party systems. - function panic() public onlyManager { - ILendingPool(lendingPool).withdraw(want, type(uint).max, address(this)); - pause(); - } - - function pause() public onlyManager { - _pause(); - - _removeAllowances(); - } - - function unpause() external onlyManager { - _unpause(); - - _giveAllowances(); - - deposit(); - } - - function _giveAllowances() internal { - IERC20(want).safeApprove(lendingPool, uint256(-1)); - IERC20(native).safeApprove(unirouter, uint256(-1)); - } - - function _removeAllowances() internal { - IERC20(want).safeApprove(lendingPool, 0); - IERC20(native).safeApprove(unirouter, 0); - } -} \ No newline at end of file diff --git a/contracts/BIFI/strategies/Balancer/BalancerActionsLib.sol b/contracts/BIFI/strategies/Balancer/BalancerActionsLib.sol index beef4874..1981228a 100644 --- a/contracts/BIFI/strategies/Balancer/BalancerActionsLib.sol +++ b/contracts/BIFI/strategies/Balancer/BalancerActionsLib.sol @@ -1,6 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; +import "@openzeppelin-4/contracts/token/ERC20/IERC20.sol"; import "../../interfaces/beethovenx/IBalancerVault.sol"; import "./BeefyBalancerStructs.sol"; @@ -18,6 +19,27 @@ library BalancerActionsLib { IBalancerVault(_vault).joinPool(_poolId, address(this), address(this), request); } + function multiJoin(address _vault, address _want, bytes32 _poolId, address _token0In, address _token1In, uint256 _amount0In, uint256 _amount1In) internal { + (address[] memory lpTokens,uint256[] memory balances,) = IBalancerVault(_vault).getPoolTokens(_poolId); + uint256 supply = IERC20(_want).totalSupply(); + uint256[] memory amounts = new uint256[](lpTokens.length); + for (uint256 i = 0; i < amounts.length;) { + if (lpTokens[i] == _token0In) amounts[i] = _amount0In; + else if (lpTokens[i] == _token1In) amounts[i] = _amount1In; + else amounts[i] = 0; + unchecked { ++i; } + } + + uint256 bpt0 = (amounts[0] * supply / balances[0]) - 100; + uint256 bpt1 = (amounts[1] * supply / balances[1]) - 100; + + uint256 bptOut = bpt0 > bpt1 ? bpt1 : bpt0; + bytes memory userData = abi.encode(3, bptOut); + + IBalancerVault.JoinPoolRequest memory request = IBalancerVault.JoinPoolRequest(lpTokens, amounts, userData, false); + IBalancerVault(_vault).joinPool(_poolId, address(this), address(this), request); + } + function buildSwapStructArray(BeefyBalancerStructs.BatchSwapStruct[] memory _route, uint256 _amountIn) internal pure returns (IBalancerVault.BatchSwapStep[] memory) { IBalancerVault.BatchSwapStep[] memory swaps = new IBalancerVault.BatchSwapStep[](_route.length); for (uint i; i < _route.length;) { diff --git a/contracts/BIFI/strategies/Balancer/StrategyAuraGyroMainnet.sol b/contracts/BIFI/strategies/Balancer/StrategyAuraGyroMainnet.sol new file mode 100644 index 00000000..a9dea21b --- /dev/null +++ b/contracts/BIFI/strategies/Balancer/StrategyAuraGyroMainnet.sol @@ -0,0 +1,424 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8.0; + +import "@openzeppelin-4/contracts/token/ERC20/ERC20.sol"; +import "@openzeppelin-4/contracts/token/ERC20/utils/SafeERC20.sol"; + +import "../../interfaces/aura/IAuraBooster.sol"; +import "../../interfaces/aura/IAuraRewardPool.sol"; +import "../../interfaces/beethovenx/IBalancerVault.sol"; +import "../Common/StratFeeManagerInitializable.sol"; +import "./BalancerActionsLib.sol"; +import "./BeefyBalancerStructs.sol"; +import "../../utils/UniV3Actions.sol"; + +interface IBalancerPool { + function getPoolId() external view returns (bytes32); + function getTokenRates() external view returns (uint256, uint256); +} + +contract StrategyAuraGyroMainnet is StratFeeManagerInitializable { + using SafeERC20 for IERC20; + + uint256 public constant DURATION = 1 days; + + // Tokens used + address public want; + address public output; + address public native; + address public lp0; + address public lp1; + + BeefyBalancerStructs.Input public input; + + // Third party contracts + address public booster; + address public rewardPool; + uint256 public pid; + bool public composable; + + IBalancerVault.SwapKind public swapKind; + IBalancerVault.FundManagement public funds; + + BeefyBalancerStructs.BatchSwapStruct[] public nativeToLp0Route; + BeefyBalancerStructs.BatchSwapStruct[] public lp0ToLp1Route; + BeefyBalancerStructs.BatchSwapStruct[] public outputToNativeRoute; + address[] public nativeToLp0Assets; + address[] public lp0Tolp1Assets; + address[] public outputToNativeAssets; + + mapping(address => BeefyBalancerStructs.Reward) public rewards; + address[] public rewardTokens; + + address public uniswapRouter; + bool public earmark; + bool public shouldSweep; + bool public harvestOnDeposit; + uint256 public lastHarvest; + uint256 public totalLocked; + + event StratHarvest(address indexed harvester, uint256 indexed wantHarvested, uint256 indexed tvl); + event Deposit(uint256 indexed tvl); + event Withdraw(uint256 indexed tvl); + event ChargedFees(uint256 indexed callFees, uint256 indexed beefyFees, uint256 indexed strategistFees); + + function initialize( + address _want, + BeefyBalancerStructs.BatchSwapStruct[] memory _nativeToLp0Route, + BeefyBalancerStructs.BatchSwapStruct[] memory _lp0ToLp1Route, + BeefyBalancerStructs.BatchSwapStruct[] memory _outputToNativeRoute, + address _booster, + uint256 _pid, + address[] memory _nativeToLp0, + address[] memory _lp0ToLp1, + address[] memory _outputToNative, + CommonAddresses calldata _commonAddresses + ) public initializer { + __StratFeeManager_init(_commonAddresses); + + for (uint i; i < _nativeToLp0Route.length; ++i) { + nativeToLp0Route.push(_nativeToLp0Route[i]); + } + + for (uint j; j < _lp0ToLp1Route.length; ++j) { + lp0ToLp1Route.push(_lp0ToLp1Route[j]); + } + + for (uint k; k < _outputToNativeRoute.length; ++k) { + outputToNativeRoute.push(_outputToNativeRoute[k]); + } + + want = _want; + booster = _booster; + pid = _pid; + outputToNativeAssets = _outputToNative; + nativeToLp0Assets = _nativeToLp0; + lp0Tolp1Assets = _lp0ToLp1; + output = outputToNativeAssets[0]; + native = nativeToLp0Assets[0]; + lp0 = lp0Tolp1Assets[0]; + lp1 = lp0Tolp1Assets[lp0Tolp1Assets.length - 1]; + uniswapRouter = address(0xE592427A0AEce92De3Edee1F18E0157C05861564); + shouldSweep = true; + + (,,,rewardPool,,) = IAuraBooster(booster).poolInfo(pid); + + swapKind = IBalancerVault.SwapKind.GIVEN_IN; + funds = IBalancerVault.FundManagement(address(this), false, payable(address(this)), false); + + _giveAllowances(); + } + + function deposit() public whenNotPaused { + if (shouldSweep) { + _deposit(); + } + } + + // puts the funds to work + function _deposit() internal whenNotPaused { + uint256 wantBal = IERC20(want).balanceOf(address(this)); + + if (wantBal > 0) { + IAuraBooster(booster).deposit(pid, wantBal, true); + emit Deposit(balanceOf()); + } + } + + function withdraw(uint256 _amount) external { + require(msg.sender == vault, "!vault"); + + uint256 wantBal = IERC20(want).balanceOf(address(this)); + + if (wantBal < _amount) { + IAuraRewardPool(rewardPool).withdrawAndUnwrap(_amount - wantBal, false); + wantBal = IERC20(want).balanceOf(address(this)); + } + + if (wantBal > _amount) { + wantBal = _amount; + } + + if (tx.origin != owner() && !paused()) { + uint256 withdrawalFeeAmount = wantBal * withdrawalFee / WITHDRAWAL_MAX; + wantBal = wantBal - withdrawalFeeAmount; + } + + IERC20(want).safeTransfer(vault, wantBal); + + emit Withdraw(balanceOf()); + } + + function beforeDeposit() external override { + if (harvestOnDeposit) { + require(msg.sender == vault, "!vault"); + _harvest(tx.origin); + } + } + + function harvest() external virtual { + _harvest(tx.origin); + } + + function harvest(address callFeeRecipient) external virtual { + _harvest(callFeeRecipient); + } + + function managerHarvest() external onlyManager { + _harvest(tx.origin); + } + + // compounds earnings and charges performance fee + function _harvest(address callFeeRecipient) internal whenNotPaused { + if (earmark) IAuraBooster(booster).earmarkRewards(pid); + IAuraRewardPool(rewardPool).getReward(); + swapRewardsToNative(); + uint256 nativeBal = IERC20(native).balanceOf(address(this)); + uint256 before = balanceOfWant(); + + if (nativeBal > 0) { + chargeFees(callFeeRecipient); + addLiquidity(); + uint256 wantHarvested = balanceOfWant() - before; + totalLocked = wantHarvested + lockedProfit(); + _deposit(); + + lastHarvest = block.timestamp; + emit StratHarvest(msg.sender, wantHarvested, balanceOf()); + } + } + + function swapRewardsToNative() internal { + uint256 outputBal = IERC20(output).balanceOf(address(this)); + if (outputBal > 0) { + IBalancerVault.BatchSwapStep[] memory _swaps = BalancerActionsLib.buildSwapStructArray(outputToNativeRoute, outputBal); + BalancerActionsLib.balancerSwap(unirouter, swapKind, _swaps, outputToNativeAssets, funds, int256(outputBal)); + } + // extras + for (uint i; i < rewardTokens.length; ++i) { + uint bal = IERC20(rewardTokens[i]).balanceOf(address(this)); + if (bal >= rewards[rewardTokens[i]].minAmount) { + if (rewards[rewardTokens[i]].assets[0] != address(0)) { + BeefyBalancerStructs.BatchSwapStruct[] memory swapInfo = new BeefyBalancerStructs.BatchSwapStruct[](rewards[rewardTokens[i]].assets.length - 1); + for (uint j; j < rewards[rewardTokens[i]].assets.length - 1;) { + swapInfo[j] = rewards[rewardTokens[i]].swapInfo[j]; + unchecked { + ++j; + } + } + IBalancerVault.BatchSwapStep[] memory _swaps = BalancerActionsLib.buildSwapStructArray(swapInfo, bal); + BalancerActionsLib.balancerSwap(unirouter, swapKind, _swaps, rewards[rewardTokens[i]].assets, funds, int256(bal)); + } else { + UniV3Actions.swapV3WithDeadline(uniswapRouter, rewards[rewardTokens[i]].routeToNative, bal); + } + } + } + } + + // performance fees + function chargeFees(address callFeeRecipient) internal { + IFeeConfig.FeeCategory memory fees = getFees(); + uint256 nativeBal = IERC20(native).balanceOf(address(this)) * fees.total / DIVISOR; + + uint256 callFeeAmount = nativeBal * fees.call / DIVISOR; + IERC20(native).safeTransfer(callFeeRecipient, callFeeAmount); + + uint256 beefyFeeAmount = nativeBal * fees.beefy / DIVISOR; + IERC20(native).safeTransfer(beefyFeeRecipient, beefyFeeAmount); + + uint256 strategistFeeAmount = nativeBal * fees.strategist / DIVISOR; + IERC20(native).safeTransfer(strategist, strategistFeeAmount); + + emit ChargedFees(callFeeAmount, beefyFeeAmount, strategistFeeAmount); + } + + // Adds liquidity to AMM and gets more LP tokens. + function addLiquidity() internal { + uint256 nativeBal = IERC20(native).balanceOf(address(this)); + bytes32 poolId = IBalancerPool(want).getPoolId(); + (address[] memory lpTokens,,) = IBalancerVault(unirouter).getPoolTokens(poolId); + + if (lpTokens[0] != native) { + IBalancerVault.BatchSwapStep[] memory _swaps = BalancerActionsLib.buildSwapStructArray(nativeToLp0Route, nativeBal); + BalancerActionsLib.balancerSwap(unirouter, swapKind, _swaps, nativeToLp0Assets, funds, int256(nativeBal)); + } + + if (nativeBal > 0) { + uint256 lp0Bal = IERC20(lpTokens[0]).balanceOf(address(this)); + (uint256 lp0Amt, uint256 lp1Amt) = _calcSwapAmount(lp0Bal); + + IBalancerVault.BatchSwapStep[] memory _swaps = BalancerActionsLib.buildSwapStructArray(lp0ToLp1Route, lp1Amt); + BalancerActionsLib.balancerSwap(unirouter, swapKind, _swaps, lp0Tolp1Assets, funds, int256(lp1Amt)); + + BalancerActionsLib.multiJoin(unirouter, want, poolId, lpTokens[0], lpTokens[1], lp0Amt, IERC20(lpTokens[1]).balanceOf(address(this))); + } + } + + function _calcSwapAmount(uint256 _bal) private view returns (uint256 lp0Amt, uint256 lp1Amt) { + lp0Amt = _bal / 2; + lp1Amt = _bal - lp0Amt; + + (uint256 rate0, uint256 rate1) = IBalancerPool(want).getTokenRates(); + + (, uint256[] memory balances,) = IBalancerVault(unirouter).getPoolTokens(IBalancerPool(want).getPoolId()); + uint256 supply = IERC20(want).totalSupply(); + + uint256 amountA = balances[0] * 1e18 / supply; + uint256 amountB = balances[1] * 1e18 / supply; + + uint256 ratio = rate0 * 1e18 / rate1 * amountB / amountA; + lp0Amt = _bal * 1e18 / (ratio + 1e18); + lp1Amt = _bal - lp0Amt; + } + + function lockedProfit() public view returns (uint256) { + uint256 elapsed = block.timestamp - lastHarvest; + uint256 remaining = elapsed < DURATION ? DURATION - elapsed : 0; + return totalLocked * remaining / DURATION; + } + + // calculate the total underlaying 'want' held by the strat. + function balanceOf() public view returns (uint256) { + return balanceOfWant() + balanceOfPool() - lockedProfit(); + } + + // it calculates how much 'want' this contract holds. + function balanceOfWant() public view returns (uint256) { + return IERC20(want).balanceOf(address(this)); + } + + // it calculates how much 'want' the strategy has working in the farm. + function balanceOfPool() public view returns (uint256) { + return IAuraRewardPool(rewardPool).balanceOf(address(this)); + } + + // returns rewards unharvested + function rewardsAvailable() public view returns (uint256) { + return IAuraRewardPool(rewardPool).earned(address(this)); + } + + // native reward amount for calling harvest + function callReward() public pure returns (uint256) { + return 0; // multiple swap providers with no easy way to estimate native output. + } + + function addRewardToken(address _token, BeefyBalancerStructs.BatchSwapStruct[] memory _swapInfo, address[] memory _assets, bytes calldata _routeToNative, uint _minAmount) external onlyOwner { + require(_token != want, "!want"); + require(_token != native, "!native"); + if (_assets[0] != address(0)) { + IERC20(_token).safeApprove(unirouter, 0); + IERC20(_token).safeApprove(unirouter, type(uint).max); + } else { + IERC20(_token).safeApprove(uniswapRouter, 0); + IERC20(_token).safeApprove(uniswapRouter, type(uint).max); + } + + rewards[_token].assets = _assets; + rewards[_token].routeToNative = _routeToNative; + rewards[_token].minAmount = _minAmount; + + for (uint i; i < _swapInfo.length; ++i) { + rewards[_token].swapInfo[i].poolId = _swapInfo[i].poolId; + rewards[_token].swapInfo[i].assetInIndex = _swapInfo[i].assetInIndex; + rewards[_token].swapInfo[i].assetOutIndex = _swapInfo[i].assetOutIndex; + } + rewardTokens.push(_token); + } + + function resetRewardTokens() external onlyManager { + for (uint i; i < rewardTokens.length; ++i) { + delete rewards[rewardTokens[i]]; + } + delete rewardTokens; + } + + function setHarvestOnDeposit(bool _harvestOnDeposit) external onlyManager { + harvestOnDeposit = _harvestOnDeposit; + + if (harvestOnDeposit) { + setWithdrawalFee(0); + } else { + setWithdrawalFee(10); + } + } + + function setEarmark(bool _earmark) external onlyManager { + earmark = _earmark; + } + + function setShouldSweep(bool _shouldSweep) external onlyManager { + shouldSweep = _shouldSweep; + } + + // called as part of strat migration. Sends all the available funds back to the vault. + function retireStrat() external { + require(msg.sender == vault, "!vault"); + + IAuraRewardPool(rewardPool).withdrawAndUnwrap(balanceOfPool(), false); + + uint256 wantBal = IERC20(want).balanceOf(address(this)); + IERC20(want).transfer(vault, wantBal); + } + + // pauses deposits and withdraws all funds from third party systems. + function panic() public onlyManager { + pause(); + IAuraRewardPool(rewardPool).withdrawAndUnwrap(balanceOfPool(), false); + } + + function pause() public onlyManager { + _pause(); + + _removeAllowances(); + } + + function unpause() external onlyManager { + _unpause(); + + _giveAllowances(); + + deposit(); + } + + function _giveAllowances() internal { + IERC20(want).safeApprove(booster, type(uint).max); + IERC20(output).safeApprove(unirouter, type(uint).max); + IERC20(native).safeApprove(unirouter, type(uint).max); + + IERC20(lp0).safeApprove(unirouter, 0); + IERC20(lp0).safeApprove(unirouter, type(uint).max); + + IERC20(lp1).safeApprove(unirouter, 0); + IERC20(lp1).safeApprove(unirouter, type(uint).max); + + if (rewardTokens.length != 0) { + for (uint i; i < rewardTokens.length; ++i) { + if (rewards[rewardTokens[i]].assets[0] != address(0)) { + IERC20(rewardTokens[i]).safeApprove(unirouter, 0); + IERC20(rewardTokens[i]).safeApprove(unirouter, type(uint).max); + } else { + IERC20(rewardTokens[i]).safeApprove(uniswapRouter, 0); + IERC20(rewardTokens[i]).safeApprove(uniswapRouter, type(uint).max); + } + } + } + } + + function _removeAllowances() internal { + IERC20(want).safeApprove(booster, 0); + IERC20(output).safeApprove(unirouter, 0); + IERC20(native).safeApprove(unirouter, 0); + IERC20(lp0).safeApprove(unirouter, 0); + IERC20(lp1).safeApprove(unirouter, 0); + if (rewardTokens.length != 0) { + for (uint i; i < rewardTokens.length; ++i) { + if (rewards[rewardTokens[i]].assets[0] != address(0)) { + IERC20(rewardTokens[i]).safeApprove(unirouter, 0); + } else { + IERC20(rewardTokens[i]).safeApprove(uniswapRouter, 0); + } + } + } + } +} \ No newline at end of file diff --git a/contracts/BIFI/strategies/Ellipsis/IEpsSwap.sol b/contracts/BIFI/strategies/Ellipsis/IEpsSwap.sol index d88338fc..d9fdf416 100644 --- a/contracts/BIFI/strategies/Ellipsis/IEpsSwap.sol +++ b/contracts/BIFI/strategies/Ellipsis/IEpsSwap.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.6.0; +pragma solidity ^0.8.0; interface IEpsSwap { function get_dy(int128 i, int128 j, uint256 dx) external view returns (uint256); diff --git a/contracts/BIFI/infra/BeFTMClaimer.sol b/contracts/archive/infra/BeFTMClaimer.sol similarity index 100% rename from contracts/BIFI/infra/BeFTMClaimer.sol rename to contracts/archive/infra/BeFTMClaimer.sol diff --git a/contracts/BIFI/infra/BeefyFeeBatch.sol b/contracts/archive/infra/BeefyFeeBatch.sol similarity index 100% rename from contracts/BIFI/infra/BeefyFeeBatch.sol rename to contracts/archive/infra/BeefyFeeBatch.sol diff --git a/contracts/BIFI/infra/BeefyFeeBatchV2.sol b/contracts/archive/infra/BeefyFeeBatchV2.sol similarity index 100% rename from contracts/BIFI/infra/BeefyFeeBatchV2.sol rename to contracts/archive/infra/BeefyFeeBatchV2.sol diff --git a/contracts/BIFI/infra/BeefyLaunchpool.sol b/contracts/archive/infra/BeefyLaunchpool.sol similarity index 100% rename from contracts/BIFI/infra/BeefyLaunchpool.sol rename to contracts/archive/infra/BeefyLaunchpool.sol diff --git a/contracts/BIFI/infra/BeefyVeRewardPool.sol b/contracts/archive/infra/BeefyVeRewardPool.sol similarity index 100% rename from contracts/BIFI/infra/BeefyVeRewardPool.sol rename to contracts/archive/infra/BeefyVeRewardPool.sol diff --git a/contracts/BIFI/interfaces/DFYN/IStakingRewards.sol b/contracts/archive/interfaces/DFYN/IStakingRewards.sol similarity index 100% rename from contracts/BIFI/interfaces/DFYN/IStakingRewards.sol rename to contracts/archive/interfaces/DFYN/IStakingRewards.sol diff --git a/contracts/BIFI/interfaces/alpaca/IAlpacaVault.sol b/contracts/archive/interfaces/alpaca/IAlpacaVault.sol similarity index 100% rename from contracts/BIFI/interfaces/alpaca/IAlpacaVault.sol rename to contracts/archive/interfaces/alpaca/IAlpacaVault.sol diff --git a/contracts/BIFI/interfaces/alpaca/IFairLaunch.sol b/contracts/archive/interfaces/alpaca/IFairLaunch.sol similarity index 100% rename from contracts/BIFI/interfaces/alpaca/IFairLaunch.sol rename to contracts/archive/interfaces/alpaca/IFairLaunch.sol diff --git a/contracts/BIFI/interfaces/beefy/IBurningStrategy.sol b/contracts/archive/interfaces/beefy/IBurningStrategy.sol similarity index 100% rename from contracts/BIFI/interfaces/beefy/IBurningStrategy.sol rename to contracts/archive/interfaces/beefy/IBurningStrategy.sol diff --git a/contracts/BIFI/interfaces/beefy/ISeededVault.sol b/contracts/archive/interfaces/beefy/ISeededVault.sol similarity index 100% rename from contracts/BIFI/interfaces/beefy/ISeededVault.sol rename to contracts/archive/interfaces/beefy/ISeededVault.sol diff --git a/contracts/BIFI/interfaces/beefy/IUpgradeableStrategy.sol b/contracts/archive/interfaces/beefy/IUpgradeableStrategy.sol similarity index 100% rename from contracts/BIFI/interfaces/beefy/IUpgradeableStrategy.sol rename to contracts/archive/interfaces/beefy/IUpgradeableStrategy.sol diff --git a/contracts/BIFI/interfaces/beefy/IVenusStrategy.sol b/contracts/archive/interfaces/beefy/IVenusStrategy.sol similarity index 100% rename from contracts/BIFI/interfaces/beefy/IVenusStrategy.sol rename to contracts/archive/interfaces/beefy/IVenusStrategy.sol diff --git a/contracts/BIFI/interfaces/beefy/IVenusStrategyBNB.sol b/contracts/archive/interfaces/beefy/IVenusStrategyBNB.sol similarity index 100% rename from contracts/BIFI/interfaces/beefy/IVenusStrategyBNB.sol rename to contracts/archive/interfaces/beefy/IVenusStrategyBNB.sol diff --git a/contracts/BIFI/interfaces/belt/IBeltLP.sol b/contracts/archive/interfaces/belt/IBeltLP.sol similarity index 100% rename from contracts/BIFI/interfaces/belt/IBeltLP.sol rename to contracts/archive/interfaces/belt/IBeltLP.sol diff --git a/contracts/BIFI/interfaces/belt/IBeltToken.sol b/contracts/archive/interfaces/belt/IBeltToken.sol similarity index 100% rename from contracts/BIFI/interfaces/belt/IBeltToken.sol rename to contracts/archive/interfaces/belt/IBeltToken.sol diff --git a/contracts/BIFI/interfaces/belt/IMasterBelt.sol b/contracts/archive/interfaces/belt/IMasterBelt.sol similarity index 100% rename from contracts/BIFI/interfaces/belt/IMasterBelt.sol rename to contracts/archive/interfaces/belt/IMasterBelt.sol diff --git a/contracts/BIFI/interfaces/binance/IRewardRegister.sol b/contracts/archive/interfaces/binance/IRewardRegister.sol similarity index 100% rename from contracts/BIFI/interfaces/binance/IRewardRegister.sol rename to contracts/archive/interfaces/binance/IRewardRegister.sol diff --git a/contracts/BIFI/interfaces/biswap/IBiswapChef.sol b/contracts/archive/interfaces/biswap/IBiswapChef.sol similarity index 100% rename from contracts/BIFI/interfaces/biswap/IBiswapChef.sol rename to contracts/archive/interfaces/biswap/IBiswapChef.sol diff --git a/contracts/BIFI/interfaces/biswap/IBiswapPair.sol b/contracts/archive/interfaces/biswap/IBiswapPair.sol similarity index 100% rename from contracts/BIFI/interfaces/biswap/IBiswapPair.sol rename to contracts/archive/interfaces/biswap/IBiswapPair.sol diff --git a/contracts/BIFI/interfaces/biswap/IBiswapRouter.sol b/contracts/archive/interfaces/biswap/IBiswapRouter.sol similarity index 100% rename from contracts/BIFI/interfaces/biswap/IBiswapRouter.sol rename to contracts/archive/interfaces/biswap/IBiswapRouter.sol diff --git a/contracts/BIFI/interfaces/common/IBar.sol b/contracts/archive/interfaces/common/IBar.sol similarity index 100% rename from contracts/BIFI/interfaces/common/IBar.sol rename to contracts/archive/interfaces/common/IBar.sol diff --git a/contracts/BIFI/interfaces/common/ICommonRewarder.sol b/contracts/archive/interfaces/common/ICommonRewarder.sol similarity index 100% rename from contracts/BIFI/interfaces/common/ICommonRewarder.sol rename to contracts/archive/interfaces/common/ICommonRewarder.sol diff --git a/contracts/BIFI/interfaces/common/IFarm.sol b/contracts/archive/interfaces/common/IFarm.sol similarity index 100% rename from contracts/BIFI/interfaces/common/IFarm.sol rename to contracts/archive/interfaces/common/IFarm.sol diff --git a/contracts/BIFI/interfaces/stellaswap/IMasterChef.sol b/contracts/archive/interfaces/common/IMasterChef.sol similarity index 100% rename from contracts/BIFI/interfaces/stellaswap/IMasterChef.sol rename to contracts/archive/interfaces/common/IMasterChef.sol diff --git a/contracts/BIFI/interfaces/common/IMasterChefReferrer.sol b/contracts/archive/interfaces/common/IMasterChefReferrer.sol similarity index 100% rename from contracts/BIFI/interfaces/common/IMasterChefReferrer.sol rename to contracts/archive/interfaces/common/IMasterChefReferrer.sol diff --git a/contracts/BIFI/interfaces/common/IMultiFeeDistribution.sol b/contracts/archive/interfaces/common/IMultiFeeDistribution.sol similarity index 100% rename from contracts/BIFI/interfaces/common/IMultiFeeDistribution.sol rename to contracts/archive/interfaces/common/IMultiFeeDistribution.sol diff --git a/contracts/BIFI/interfaces/common/IMultiRewardPool.sol b/contracts/archive/interfaces/common/IMultiRewardPool.sol similarity index 100% rename from contracts/BIFI/interfaces/common/IMultiRewardPool.sol rename to contracts/archive/interfaces/common/IMultiRewardPool.sol diff --git a/contracts/BIFI/interfaces/common/IMultiRewards.sol b/contracts/archive/interfaces/common/IMultiRewards.sol similarity index 100% rename from contracts/BIFI/interfaces/common/IMultiRewards.sol rename to contracts/archive/interfaces/common/IMultiRewards.sol diff --git a/contracts/BIFI/interfaces/common/IStakingDualRewards.sol b/contracts/archive/interfaces/common/IStakingDualRewards.sol similarity index 100% rename from contracts/BIFI/interfaces/common/IStakingDualRewards.sol rename to contracts/archive/interfaces/common/IStakingDualRewards.sol diff --git a/contracts/BIFI/interfaces/common/IUniswapRouter.sol b/contracts/archive/interfaces/common/IUniswapRouter.sol similarity index 100% rename from contracts/BIFI/interfaces/common/IUniswapRouter.sol rename to contracts/archive/interfaces/common/IUniswapRouter.sol diff --git a/contracts/BIFI/interfaces/common/IUniswapRouterAVAX.sol b/contracts/archive/interfaces/common/IUniswapRouterAVAX.sol similarity index 100% rename from contracts/BIFI/interfaces/common/IUniswapRouterAVAX.sol rename to contracts/archive/interfaces/common/IUniswapRouterAVAX.sol diff --git a/contracts/BIFI/interfaces/common/IUniswapRouterBNB.sol b/contracts/archive/interfaces/common/IUniswapRouterBNB.sol similarity index 100% rename from contracts/BIFI/interfaces/common/IUniswapRouterBNB.sol rename to contracts/archive/interfaces/common/IUniswapRouterBNB.sol diff --git a/contracts/BIFI/interfaces/common/IUniswapRouterMATIC.sol b/contracts/archive/interfaces/common/IUniswapRouterMATIC.sol similarity index 100% rename from contracts/BIFI/interfaces/common/IUniswapRouterMATIC.sol rename to contracts/archive/interfaces/common/IUniswapRouterMATIC.sol diff --git a/contracts/BIFI/interfaces/common/IWBNB.sol b/contracts/archive/interfaces/common/IWBNB.sol similarity index 100% rename from contracts/BIFI/interfaces/common/IWBNB.sol rename to contracts/archive/interfaces/common/IWBNB.sol diff --git a/contracts/BIFI/interfaces/common/IWMATIC.sol b/contracts/archive/interfaces/common/IWMATIC.sol similarity index 100% rename from contracts/BIFI/interfaces/common/IWMATIC.sol rename to contracts/archive/interfaces/common/IWMATIC.sol diff --git a/contracts/BIFI/interfaces/dfx/IDfxRouter.sol b/contracts/archive/interfaces/dfx/IDfxRouter.sol similarity index 100% rename from contracts/BIFI/interfaces/dfx/IDfxRouter.sol rename to contracts/archive/interfaces/dfx/IDfxRouter.sol diff --git a/contracts/BIFI/interfaces/finn/IFinnBar.sol b/contracts/archive/interfaces/finn/IFinnBar.sol similarity index 100% rename from contracts/BIFI/interfaces/finn/IFinnBar.sol rename to contracts/archive/interfaces/finn/IFinnBar.sol diff --git a/contracts/BIFI/interfaces/geist/IIncentivesController.sol b/contracts/archive/interfaces/geist/IIncentivesController.sol similarity index 100% rename from contracts/BIFI/interfaces/geist/IIncentivesController.sol rename to contracts/archive/interfaces/geist/IIncentivesController.sol diff --git a/contracts/BIFI/interfaces/geist/IMultiFeeDistributer.sol b/contracts/archive/interfaces/geist/IMultiFeeDistributer.sol similarity index 100% rename from contracts/BIFI/interfaces/geist/IMultiFeeDistributer.sol rename to contracts/archive/interfaces/geist/IMultiFeeDistributer.sol diff --git a/contracts/BIFI/interfaces/hector/IStakingRewards.sol b/contracts/archive/interfaces/hector/IStakingRewards.sol similarity index 100% rename from contracts/BIFI/interfaces/hector/IStakingRewards.sol rename to contracts/archive/interfaces/hector/IStakingRewards.sol diff --git a/contracts/BIFI/interfaces/kyber/IRewardsLocker.sol b/contracts/archive/interfaces/kyber/IRewardsLocker.sol similarity index 100% rename from contracts/BIFI/interfaces/kyber/IRewardsLocker.sol rename to contracts/archive/interfaces/kyber/IRewardsLocker.sol diff --git a/contracts/BIFI/interfaces/mdex/IMasterChef.sol b/contracts/archive/interfaces/mdex/IMasterChef.sol similarity index 100% rename from contracts/BIFI/interfaces/mdex/IMasterChef.sol rename to contracts/archive/interfaces/mdex/IMasterChef.sol diff --git a/contracts/BIFI/interfaces/mdex/IMdexRouter.sol b/contracts/archive/interfaces/mdex/IMdexRouter.sol similarity index 100% rename from contracts/BIFI/interfaces/mdex/IMdexRouter.sol rename to contracts/archive/interfaces/mdex/IMdexRouter.sol diff --git a/contracts/BIFI/interfaces/mdex/ISwapMining.sol b/contracts/archive/interfaces/mdex/ISwapMining.sol similarity index 100% rename from contracts/BIFI/interfaces/mdex/ISwapMining.sol rename to contracts/archive/interfaces/mdex/ISwapMining.sol diff --git a/contracts/BIFI/interfaces/pangolin/IPangolinMiniChef.sol b/contracts/archive/interfaces/pangolin/IPangolinMiniChef.sol similarity index 100% rename from contracts/BIFI/interfaces/pangolin/IPangolinMiniChef.sol rename to contracts/archive/interfaces/pangolin/IPangolinMiniChef.sol diff --git a/contracts/BIFI/interfaces/pangolin/IPangolinRewarder.sol b/contracts/archive/interfaces/pangolin/IPangolinRewarder.sol similarity index 100% rename from contracts/BIFI/interfaces/pangolin/IPangolinRewarder.sol rename to contracts/archive/interfaces/pangolin/IPangolinRewarder.sol diff --git a/contracts/BIFI/interfaces/pangolin/IStakingRewards.sol b/contracts/archive/interfaces/pangolin/IStakingRewards.sol similarity index 100% rename from contracts/BIFI/interfaces/pangolin/IStakingRewards.sol rename to contracts/archive/interfaces/pangolin/IStakingRewards.sol diff --git a/contracts/BIFI/interfaces/quick/IDragonsLair.sol b/contracts/archive/interfaces/quick/IDragonsLair.sol similarity index 100% rename from contracts/BIFI/interfaces/quick/IDragonsLair.sol rename to contracts/archive/interfaces/quick/IDragonsLair.sol diff --git a/contracts/BIFI/interfaces/quick/IQuickConverter.sol b/contracts/archive/interfaces/quick/IQuickConverter.sol similarity index 100% rename from contracts/BIFI/interfaces/quick/IQuickConverter.sol rename to contracts/archive/interfaces/quick/IQuickConverter.sol diff --git a/contracts/BIFI/interfaces/quick/IQuickDualRewards.sol b/contracts/archive/interfaces/quick/IQuickDualRewards.sol similarity index 100% rename from contracts/BIFI/interfaces/quick/IQuickDualRewards.sol rename to contracts/archive/interfaces/quick/IQuickDualRewards.sol diff --git a/contracts/BIFI/interfaces/quick/IRewardPool.sol b/contracts/archive/interfaces/quick/IRewardPool.sol similarity index 100% rename from contracts/BIFI/interfaces/quick/IRewardPool.sol rename to contracts/archive/interfaces/quick/IRewardPool.sol diff --git a/contracts/BIFI/interfaces/scream/ISteakHouse.sol b/contracts/archive/interfaces/scream/ISteakHouse.sol similarity index 100% rename from contracts/BIFI/interfaces/scream/ISteakHouse.sol rename to contracts/archive/interfaces/scream/ISteakHouse.sol diff --git a/contracts/BIFI/interfaces/scream/IXPool.sol b/contracts/archive/interfaces/scream/IXPool.sol similarity index 100% rename from contracts/BIFI/interfaces/scream/IXPool.sol rename to contracts/archive/interfaces/scream/IXPool.sol diff --git a/contracts/BIFI/interfaces/solace/ISolaceRewards.sol b/contracts/archive/interfaces/solace/ISolaceRewards.sol similarity index 100% rename from contracts/BIFI/interfaces/solace/ISolaceRewards.sol rename to contracts/archive/interfaces/solace/ISolaceRewards.sol diff --git a/contracts/BIFI/interfaces/solace/IxLocker.sol b/contracts/archive/interfaces/solace/IxLocker.sol similarity index 100% rename from contracts/BIFI/interfaces/solace/IxLocker.sol rename to contracts/archive/interfaces/solace/IxLocker.sol diff --git a/contracts/BIFI/interfaces/solar/ISolarRouter.sol b/contracts/archive/interfaces/solar/ISolarRouter.sol similarity index 100% rename from contracts/BIFI/interfaces/solar/ISolarRouter.sol rename to contracts/archive/interfaces/solar/ISolarRouter.sol diff --git a/contracts/BIFI/interfaces/solar/ISolarStableRouter.sol b/contracts/archive/interfaces/solar/ISolarStableRouter.sol similarity index 100% rename from contracts/BIFI/interfaces/solar/ISolarStableRouter.sol rename to contracts/archive/interfaces/solar/ISolarStableRouter.sol diff --git a/contracts/BIFI/interfaces/solar/IUniswapRouterSolar.sol b/contracts/archive/interfaces/solar/IUniswapRouterSolar.sol similarity index 100% rename from contracts/BIFI/interfaces/solar/IUniswapRouterSolar.sol rename to contracts/archive/interfaces/solar/IUniswapRouterSolar.sol diff --git a/contracts/BIFI/interfaces/spirit/IMasterChef.sol b/contracts/archive/interfaces/spirit/IMasterChef.sol similarity index 100% rename from contracts/BIFI/interfaces/spirit/IMasterChef.sol rename to contracts/archive/interfaces/spirit/IMasterChef.sol diff --git a/contracts/BIFI/interfaces/tomb/IMasonry.sol b/contracts/archive/interfaces/tomb/IMasonry.sol similarity index 100% rename from contracts/BIFI/interfaces/tomb/IMasonry.sol rename to contracts/archive/interfaces/tomb/IMasonry.sol diff --git a/contracts/BIFI/interfaces/tri/ITriChef.sol b/contracts/archive/interfaces/tri/ITriChef.sol similarity index 100% rename from contracts/BIFI/interfaces/tri/ITriChef.sol rename to contracts/archive/interfaces/tri/ITriChef.sol diff --git a/contracts/BIFI/interfaces/tri/ITriRewarder.sol b/contracts/archive/interfaces/tri/ITriRewarder.sol similarity index 100% rename from contracts/BIFI/interfaces/tri/ITriRewarder.sol rename to contracts/archive/interfaces/tri/ITriRewarder.sol diff --git a/contracts/BIFI/interfaces/valleyswap/IValleySwapFarm.sol b/contracts/archive/interfaces/valleyswap/IValleySwapFarm.sol similarity index 100% rename from contracts/BIFI/interfaces/valleyswap/IValleySwapFarm.sol rename to contracts/archive/interfaces/valleyswap/IValleySwapFarm.sol diff --git a/contracts/BIFI/interfaces/valleyswap/IValleySwapLibrary.sol b/contracts/archive/interfaces/valleyswap/IValleySwapLibrary.sol similarity index 100% rename from contracts/BIFI/interfaces/valleyswap/IValleySwapLibrary.sol rename to contracts/archive/interfaces/valleyswap/IValleySwapLibrary.sol diff --git a/contracts/BIFI/interfaces/valleyswap/IValleySwapRouter.sol b/contracts/archive/interfaces/valleyswap/IValleySwapRouter.sol similarity index 100% rename from contracts/BIFI/interfaces/valleyswap/IValleySwapRouter.sol rename to contracts/archive/interfaces/valleyswap/IValleySwapRouter.sol diff --git a/contracts/BIFI/interfaces/vvs/ICraftsmanV2.sol b/contracts/archive/interfaces/vvs/ICraftsmanV2.sol similarity index 100% rename from contracts/BIFI/interfaces/vvs/ICraftsmanV2.sol rename to contracts/archive/interfaces/vvs/ICraftsmanV2.sol diff --git a/contracts/BIFI/interfaces/vvs/IVVSRewarder.sol b/contracts/archive/interfaces/vvs/IVVSRewarder.sol similarity index 100% rename from contracts/BIFI/interfaces/vvs/IVVSRewarder.sol rename to contracts/archive/interfaces/vvs/IVVSRewarder.sol diff --git a/contracts/BIFI/interfaces/yuzu/IYuzuMasterChef.sol b/contracts/archive/interfaces/yuzu/IYuzuMasterChef.sol similarity index 100% rename from contracts/BIFI/interfaces/yuzu/IYuzuMasterChef.sol rename to contracts/archive/interfaces/yuzu/IYuzuMasterChef.sol diff --git a/contracts/BIFI/interfaces/yuzu/IYuzuSwapMining.sol b/contracts/archive/interfaces/yuzu/IYuzuSwapMining.sol similarity index 100% rename from contracts/BIFI/interfaces/yuzu/IYuzuSwapMining.sol rename to contracts/archive/interfaces/yuzu/IYuzuSwapMining.sol diff --git a/contracts/archive/strategies/Aave/StrategyAave.sol b/contracts/archive/strategies/Aave/StrategyAave.sol index 9f9136f3..7fe2b1d8 100644 --- a/contracts/archive/strategies/Aave/StrategyAave.sol +++ b/contracts/archive/strategies/Aave/StrategyAave.sol @@ -9,7 +9,7 @@ import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/utils/Pausable.sol"; import "../../interfaces/aave/IDataProvider.sol"; -import "../../interfaces/aave/IIncentivesController.sol"; +import "../../interfaces/aave/IAaveV3Incentives.sol"; import "../../interfaces/aave/ILendingPool.sol"; import "../../interfaces/common/IUniswapRouterETH.sol"; import "../Common/FeeManager.sol"; @@ -20,19 +20,21 @@ contract StrategyAave is StratManager, FeeManager { using SafeMath for uint256; // Tokens used - address constant public wmatic = address(0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270); - address constant public eth = address(0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619); + address public native; address public want; address public aToken; address public varDebtToken; // Third party contracts - address constant public dataProvider = address(0x7551b5D2763519d4e37e8B81929D336De671d46d); - address constant public lendingPool = address(0x8dFf5E27EA6b7AC08EbFdf9eB090F32ee9a30fcf); - address constant public incentivesController = address(0x357D51124f59836DeD84c8a1730D72B749d8BC23); + address public dataProvider; + address public lendingPool; + address public incentivesController; // Routes - address[] public wmaticToWantRoute; + address[] public nativeToWantRoute; + + bool public harvestOnDeposit; + uint256 public lastHarvest; /** * @dev Variables that can be changed to config profitability and risk: @@ -52,22 +54,31 @@ contract StrategyAave is StratManager, FeeManager { /** * @dev Helps to differentiate borrowed funds that shouldn't be used in functions like 'deposit()' - * as they're required to deleverage correctly. + * as they're required to deleverage correctly. */ uint256 public reserves = 0; /** * @dev Events that the contract emits */ - event StratHarvest(address indexed harvester); + event StratHarvest(address indexed harvester, uint256 wantHarvested, uint256 tvl); + event Deposit(uint256 tvl); + event Withdraw(uint256 tvl); + event ChargedFees(uint256 callFees, uint256 beefyFees, uint256 strategistFees); event StratRebalance(uint256 _borrowRate, uint256 _borrowDepth); + event SetEMode(uint8 eMode, uint256 borrowRateMax, uint256 borrowRate, uint256 borrowDepth); constructor( address _want, + address _native, uint256 _borrowRate, uint256 _borrowRateMax, uint256 _borrowDepth, uint256 _minLeverage, + uint8 _eMode, + address _dataProvider, + address _lendingPool, + address _incentivesController, address _vault, address _unirouter, address _keeper, @@ -75,19 +86,24 @@ contract StrategyAave is StratManager, FeeManager { address _beefyFeeRecipient ) StratManager(_keeper, _strategist, _unirouter, _vault, _beefyFeeRecipient) public { want = _want; - (aToken,,varDebtToken) = IDataProvider(dataProvider).getReserveTokensAddresses(want); + native = _native; borrowRate = _borrowRate; borrowRateMax = _borrowRateMax; borrowDepth = _borrowDepth; minLeverage = _minLeverage; + dataProvider = _dataProvider; + lendingPool = _lendingPool; + incentivesController = _incentivesController; + + (aToken,,varDebtToken) = IDataProvider(dataProvider).getReserveTokensAddresses(want); - if (want == eth) { - wmaticToWantRoute = [wmatic, eth]; - } else if (want != wmatic) { - wmaticToWantRoute = [wmatic, eth, want]; + if (_eMode != 0) { + ILendingPool(lendingPool).setUserEMode(_eMode); } + nativeToWantRoute = [native, want]; + _giveAllowances(); } @@ -97,6 +113,7 @@ contract StrategyAave is StratManager, FeeManager { if (wantBal > 0) { _leverage(wantBal); + emit Deposit(balanceOf()); } } @@ -110,20 +127,21 @@ contract StrategyAave is StratManager, FeeManager { for (uint i = 0; i < borrowDepth; i++) { ILendingPool(lendingPool).deposit(want, _amount, address(this), 0); _amount = _amount.mul(borrowRate).div(100); - ILendingPool(lendingPool).borrow(want, _amount, INTEREST_RATE_MODE, 0, address(this)); + if (_amount > 0) { + ILendingPool(lendingPool).borrow(want, _amount, INTEREST_RATE_MODE, 0, address(this)); + } } reserves = reserves.add(_amount); } - /** * @dev Incrementally alternates between paying part of the debt and withdrawing part of the supplied * collateral. Continues to do this until it repays the entire debt and withdraws all the supplied {want} * from the system */ function _deleverage() internal { - uint256 wantBal = IERC20(want).balanceOf(address(this)); + uint256 wantBal = balanceOfWant(); (uint256 supplyBal, uint256 borrowBal) = userReserves(); while (wantBal < borrowBal) { @@ -133,11 +151,15 @@ contract StrategyAave is StratManager, FeeManager { uint256 targetSupply = borrowBal.mul(100).div(borrowRate); ILendingPool(lendingPool).withdraw(want, supplyBal.sub(targetSupply), address(this)); - wantBal = IERC20(want).balanceOf(address(this)); + wantBal = balanceOfWant(); } - ILendingPool(lendingPool).repay(want, uint256(-1), INTEREST_RATE_MODE, address(this)); - ILendingPool(lendingPool).withdraw(want, type(uint).max, address(this)); + if (borrowBal > 0) { + ILendingPool(lendingPool).repay(want, uint256(-1), INTEREST_RATE_MODE, address(this)); + } + if (supplyBal > 0) { + ILendingPool(lendingPool).withdraw(want, type(uint).max, address(this)); + } reserves = 0; } @@ -151,16 +173,19 @@ contract StrategyAave is StratManager, FeeManager { function deleverageOnce(uint _borrowRate) external onlyManager { require(_borrowRate <= borrowRateMax, "!safe"); - uint256 wantBal = IERC20(want).balanceOf(address(this)); - ILendingPool(lendingPool).repay(want, wantBal, INTEREST_RATE_MODE, address(this)); + uint256 wantBal = balanceOfWant(); + if (wantBal > 0) { + ILendingPool(lendingPool).repay(want, wantBal, INTEREST_RATE_MODE, address(this)); + } (uint256 supplyBal, uint256 borrowBal) = userReserves(); uint256 targetSupply = borrowBal.mul(100).div(_borrowRate); - ILendingPool(lendingPool).withdraw(want, supplyBal.sub(targetSupply), address(this)); + if (supplyBal.sub(targetSupply) > 0) { + ILendingPool(lendingPool).withdraw(want, supplyBal.sub(targetSupply), address(this)); + } - wantBal = IERC20(want).balanceOf(address(this)); - reserves = wantBal; + reserves = balanceOfWant(); } /** @@ -176,44 +201,70 @@ contract StrategyAave is StratManager, FeeManager { borrowRate = _borrowRate; borrowDepth = _borrowDepth; - uint256 wantBal = IERC20(want).balanceOf(address(this)); + uint256 wantBal = balanceOfWant(); _leverage(wantBal); - StratRebalance(_borrowRate, _borrowDepth); + emit StratRebalance(_borrowRate, _borrowDepth); + } + + function beforeDeposit() external override { + if (harvestOnDeposit) { + require(msg.sender == vault, "!vault"); + _harvest(tx.origin); + } + } + + function harvest() external virtual { + _harvest(tx.origin); + } + + function harvest(address callFeeRecipient) external virtual { + _harvest(callFeeRecipient); + } + + function managerHarvest() external onlyManager { + _harvest(tx.origin); } // compounds earnings and charges performance fee - function harvest() external whenNotPaused { + function _harvest(address callFeeRecipient) internal whenNotPaused { address[] memory assets = new address[](2); assets[0] = aToken; assets[1] = varDebtToken; - IIncentivesController(incentivesController).claimRewards(assets, type(uint).max, address(this)); + IAaveV3Incentives(incentivesController).claimRewards(assets, type(uint).max, address(this), native); - chargeFees(); - swapRewards(); - deposit(); + uint256 nativeBal = IERC20(native).balanceOf(address(this)); + if (nativeBal > 0) { + chargeFees(callFeeRecipient); + swapRewards(); + uint256 wantHarvested = availableWant(); + deposit(); - emit StratHarvest(msg.sender); + lastHarvest = block.timestamp; + emit StratHarvest(msg.sender, wantHarvested, balanceOf()); + } } // performance fees - function chargeFees() internal { - uint256 wmaticFeeBal = IERC20(wmatic).balanceOf(address(this)).mul(45).div(1000); + function chargeFees(address callFeeRecipient) internal { + uint256 nativeFeeBal = IERC20(native).balanceOf(address(this)).mul(45).div(1000); + + uint256 callFeeAmount = nativeFeeBal.mul(callFee).div(MAX_FEE); + IERC20(native).safeTransfer(callFeeRecipient, callFeeAmount); - uint256 callFeeAmount = wmaticFeeBal.mul(callFee).div(MAX_FEE); - IERC20(wmatic).safeTransfer(tx.origin, callFeeAmount); + uint256 beefyFeeAmount = nativeFeeBal.mul(beefyFee).div(MAX_FEE); + IERC20(native).safeTransfer(beefyFeeRecipient, beefyFeeAmount); - uint256 beefyFeeAmount = wmaticFeeBal.mul(beefyFee).div(MAX_FEE); - IERC20(wmatic).safeTransfer(beefyFeeRecipient, beefyFeeAmount); + uint256 strategistFeeAmount = nativeFeeBal.mul(STRATEGIST_FEE).div(MAX_FEE); + IERC20(native).safeTransfer(strategist, strategistFeeAmount); - uint256 strategistFee = wmaticFeeBal.mul(STRATEGIST_FEE).div(MAX_FEE); - IERC20(wmatic).safeTransfer(strategist, strategistFee); + emit ChargedFees(callFeeAmount, beefyFeeAmount, strategistFeeAmount); } // swap rewards to {want} function swapRewards() internal { - uint256 wmaticBal = IERC20(wmatic).balanceOf(address(this)); - IUniswapRouterETH(unirouter).swapExactTokensForTokens(wmaticBal, 0, wmaticToWantRoute, address(this), now); + uint256 nativeBal = IERC20(native).balanceOf(address(this)); + IUniswapRouterETH(unirouter).swapExactTokensForTokens(nativeBal, 0, nativeToWantRoute, address(this), now); } /** @@ -225,23 +276,23 @@ contract StrategyAave is StratManager, FeeManager { require(msg.sender == vault, "!vault"); uint256 wantBal = availableWant(); - if (wantBal < _amount) { _deleverage(); - wantBal = IERC20(want).balanceOf(address(this)); + wantBal = balanceOfWant(); } if (wantBal > _amount) { wantBal = _amount; } - if (tx.origin == owner() || paused()) { - IERC20(want).safeTransfer(vault, wantBal); - } else { + if (tx.origin != owner() && !paused()) { uint256 withdrawalFeeAmount = wantBal.mul(withdrawalFee).div(WITHDRAWAL_MAX); - IERC20(want).safeTransfer(vault, wantBal.sub(withdrawalFeeAmount)); + wantBal = wantBal.sub(withdrawalFeeAmount); } + IERC20(want).safeTransfer(vault, wantBal); + emit Withdraw(balanceOf()); + if (!paused()) { _leverage(availableWant()); } @@ -252,8 +303,7 @@ contract StrategyAave is StratManager, FeeManager { * @return how much {want} the contract holds without reserves */ function availableWant() public view returns (uint256) { - uint256 wantBal = IERC20(want).balanceOf(address(this)); - return wantBal.sub(reserves); + return balanceOfWant().sub(reserves); } // return supply and borrow balance @@ -290,13 +340,66 @@ contract StrategyAave is StratManager, FeeManager { return supplyBal.sub(borrowBal); } + function nativeToWant() public view returns (address[] memory) { + return nativeToWantRoute; + } + + // returns rewards unharvested + function rewardsAvailable() public view returns (uint256) { + address[] memory assets = new address[](2); + assets[0] = aToken; + assets[1] = varDebtToken; + return IAaveV3Incentives(incentivesController).getUserRewards(assets, address(this), native); + } + + // native reward amount for calling harvest + function callReward() public view returns (uint256) { + return rewardsAvailable().mul(45).div(1000).mul(callFee).div(MAX_FEE); + } + + // returns strategy's eMode + function eMode() external view returns (uint256) { + return ILendingPool(lendingPool).getUserEMode(address(this)); + } + + // set strategy to a new eMode and set borrowRateMax to the loan-to-value of the new eMode category + function setEMode(uint8 _eMode, uint256 _borrowRateMax, uint256 _borrowRate, uint256 _borrowDepth) external onlyManager { + _deleverage(); + ILendingPool(lendingPool).setUserEMode(_eMode); + + if (_eMode != 0) { + (uint16 ltv,,,,) = ILendingPool(lendingPool).getEModeCategoryData(_eMode); + borrowRateMax = uint256(ltv).div(100); + } else { + borrowRateMax = _borrowRateMax; + } + + require(_borrowRate <= borrowRateMax, "!rate"); + require(_borrowDepth <= BORROW_DEPTH_MAX, "!depth"); + borrowRate = _borrowRate; + borrowDepth = _borrowDepth; + + _leverage(balanceOfWant()); + + emit SetEMode(_eMode, borrowRateMax, borrowRate, borrowDepth); + } + + function setHarvestOnDeposit(bool _harvestOnDeposit) external onlyManager { + harvestOnDeposit = _harvestOnDeposit; + if (harvestOnDeposit) { + setWithdrawalFee(0); + } else { + setWithdrawalFee(10); + } + } + // called as part of strat migration. Sends all the available funds back to the vault. function retireStrat() external { require(msg.sender == vault, "!vault"); _deleverage(); - uint256 wantBal = IERC20(want).balanceOf(address(this)); + uint256 wantBal = balanceOfWant(); IERC20(want).transfer(vault, wantBal); } @@ -322,11 +425,11 @@ contract StrategyAave is StratManager, FeeManager { function _giveAllowances() internal { IERC20(want).safeApprove(lendingPool, uint256(-1)); - IERC20(wmatic).safeApprove(unirouter, uint256(-1)); + IERC20(native).safeApprove(unirouter, uint256(-1)); } function _removeAllowances() internal { IERC20(want).safeApprove(lendingPool, 0); - IERC20(wmatic).safeApprove(unirouter, 0); + IERC20(native).safeApprove(unirouter, 0); } -} \ No newline at end of file +} \ No newline at end of file diff --git a/contracts/BIFI/strategies/Aave/StrategyAaveNative.sol b/contracts/archive/strategies/Aave/StrategyAaveNative.sol similarity index 100% rename from contracts/BIFI/strategies/Aave/StrategyAaveNative.sol rename to contracts/archive/strategies/Aave/StrategyAaveNative.sol diff --git a/contracts/archive/strategies/Aave/StrategyAaveSupplyOnly.sol b/contracts/archive/strategies/Aave/StrategyAaveSupplyOnly.sol index 92750a53..b88fec91 100644 --- a/contracts/archive/strategies/Aave/StrategyAaveSupplyOnly.sol +++ b/contracts/archive/strategies/Aave/StrategyAaveSupplyOnly.sol @@ -9,7 +9,7 @@ import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/utils/Pausable.sol"; import "../../interfaces/aave/IDataProvider.sol"; -import "../../interfaces/aave/IIncentivesController.sol"; +import "../../interfaces/aave/IAaveV3Incentives.sol"; import "../../interfaces/aave/ILendingPool.sol"; import "../../interfaces/common/IUniswapRouterETH.sol"; import "../Common/FeeManager.sol"; @@ -20,26 +20,32 @@ contract StrategyAaveSupplyOnly is StratManager, FeeManager { using SafeMath for uint256; // Tokens used - address constant public wmatic = address(0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270); - address constant public eth = address(0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619); + address public native; address public want; address public aToken; // Third party contracts - address constant public dataProvider = address(0x7551b5D2763519d4e37e8B81929D336De671d46d); - address constant public lendingPool = address(0x8dFf5E27EA6b7AC08EbFdf9eB090F32ee9a30fcf); - address constant public incentivesController = address(0x357D51124f59836DeD84c8a1730D72B749d8BC23); + address public dataProvider; + address public lendingPool; + address public incentivesController; // Routes - address[] public wmaticToWantRoute; + address[] public nativeToWantRoute; - /** - * @dev Events that the contract emits - */ - event StratHarvest(address indexed harvester); + bool public harvestOnDeposit; + uint256 public lastHarvest; + + event StratHarvest(address indexed harvester, uint256 wantHarvested, uint256 tvl); + event Deposit(uint256 tvl); + event Withdraw(uint256 tvl); + event ChargedFees(uint256 callFees, uint256 beefyFees, uint256 strategistFees); constructor( address _want, + address _native, + address _dataProvider, + address _lendingPool, + address _incentivesController, address _vault, address _unirouter, address _keeper, @@ -47,79 +53,108 @@ contract StrategyAaveSupplyOnly is StratManager, FeeManager { address _beefyFeeRecipient ) StratManager(_keeper, _strategist, _unirouter, _vault, _beefyFeeRecipient) public { want = _want; + native = _native; + + dataProvider = _dataProvider; + lendingPool = _lendingPool; + incentivesController = _incentivesController; + (aToken,,) = IDataProvider(dataProvider).getReserveTokensAddresses(want); - if (want == eth) { - wmaticToWantRoute = [wmatic, eth]; - } else if (want != wmatic) { - wmaticToWantRoute = [wmatic, eth, want]; - } + nativeToWantRoute = [native, want]; _giveAllowances(); } // puts the funds to work function deposit() public whenNotPaused { - uint256 wantBal = IERC20(want).balanceOf(address(this)); + uint256 wantBal = balanceOfWant(); if (wantBal > 0) { ILendingPool(lendingPool).deposit(want, wantBal, address(this), 0); + emit Deposit(balanceOf()); } } function withdraw(uint256 _amount) external { require(msg.sender == vault, "!vault"); - uint256 wantBal = IERC20(want).balanceOf(address(this)); - + uint256 wantBal = balanceOfWant(); if (wantBal < _amount) { ILendingPool(lendingPool).withdraw(want, _amount.sub(wantBal), address(this)); - wantBal = IERC20(want).balanceOf(address(this)); + wantBal = balanceOfWant(); } if (wantBal > _amount) { wantBal = _amount; } - if (tx.origin == owner() || paused()) { - IERC20(want).safeTransfer(vault, wantBal); - } else { + if (tx.origin != owner() && !paused()) { uint256 withdrawalFeeAmount = wantBal.mul(withdrawalFee).div(WITHDRAWAL_MAX); - IERC20(want).safeTransfer(vault, wantBal.sub(withdrawalFeeAmount)); + wantBal = wantBal.sub(withdrawalFeeAmount); + } + + IERC20(want).safeTransfer(vault, wantBal); + emit Withdraw(balanceOf()); + } + + function beforeDeposit() external override { + if (harvestOnDeposit) { + require(msg.sender == vault, "!vault"); + _harvest(tx.origin); } } + function harvest() external virtual { + _harvest(tx.origin); + } + + function harvest(address callFeeRecipient) external virtual { + _harvest(callFeeRecipient); + } + + function managerHarvest() external onlyManager { + _harvest(tx.origin); + } + // compounds earnings and charges performance fee - function harvest() external whenNotPaused { + function _harvest(address callFeeRecipient) internal whenNotPaused { address[] memory assets = new address[](1); assets[0] = aToken; - IIncentivesController(incentivesController).claimRewards(assets, type(uint).max, address(this)); + IAaveV3Incentives(incentivesController).claimRewards(assets, type(uint).max, address(this), native); - chargeFees(); - swapRewards(); - deposit(); + uint256 nativeBal = IERC20(native).balanceOf(address(this)); + if (nativeBal > 0) { + chargeFees(callFeeRecipient); + swapRewards(); + uint256 wantHarvested = balanceOfWant(); + deposit(); - emit StratHarvest(msg.sender); + lastHarvest = block.timestamp; + emit StratHarvest(msg.sender, wantHarvested, balanceOf()); + } } // performance fees - function chargeFees() internal { - uint256 wmaticFeeBal = IERC20(wmatic).balanceOf(address(this)).mul(45).div(1000); + function chargeFees(address callFeeRecipient) internal { + uint256 nativeFeeBal = IERC20(native).balanceOf(address(this)).mul(45).div(1000); - uint256 callFeeAmount = wmaticFeeBal.mul(callFee).div(MAX_FEE); - IERC20(wmatic).safeTransfer(tx.origin, callFeeAmount); + uint256 callFeeAmount = nativeFeeBal.mul(callFee).div(MAX_FEE); + IERC20(native).safeTransfer(callFeeRecipient, callFeeAmount); - uint256 beefyFeeAmount = wmaticFeeBal.mul(beefyFee).div(MAX_FEE); - IERC20(wmatic).safeTransfer(beefyFeeRecipient, beefyFeeAmount); + uint256 beefyFeeAmount = nativeFeeBal.mul(beefyFee).div(MAX_FEE); + IERC20(native).safeTransfer(beefyFeeRecipient, beefyFeeAmount); - uint256 strategistFee = wmaticFeeBal.mul(STRATEGIST_FEE).div(MAX_FEE); - IERC20(wmatic).safeTransfer(strategist, strategistFee); + uint256 strategistFeeAmount = nativeFeeBal.mul(STRATEGIST_FEE).div(MAX_FEE); + IERC20(native).safeTransfer(strategist, strategistFeeAmount); + + emit ChargedFees(callFeeAmount, beefyFeeAmount, strategistFeeAmount); } // swap rewards to {want} function swapRewards() internal { - uint256 wmaticBal = IERC20(wmatic).balanceOf(address(this)); - IUniswapRouterETH(unirouter).swapExactTokensForTokens(wmaticBal, 0, wmaticToWantRoute, address(this), now); + uint256 nativeBal = IERC20(native).balanceOf(address(this)); + IUniswapRouterETH(unirouter).swapExactTokensForTokens(nativeBal, 0, nativeToWantRoute, address(this), now); } // return supply and borrow balance @@ -156,13 +191,38 @@ contract StrategyAaveSupplyOnly is StratManager, FeeManager { return supplyBal.sub(borrowBal); } + function nativeToWant() public view returns (address[] memory) { + return nativeToWantRoute; + } + + // returns rewards unharvested + function rewardsAvailable() public view returns (uint256) { + address[] memory assets = new address[](1); + assets[0] = aToken; + return IAaveV3Incentives(incentivesController).getUserRewards(assets, address(this), native); + } + + // native reward amount for calling harvest + function callReward() public view returns (uint256) { + return rewardsAvailable().mul(45).div(1000).mul(callFee).div(MAX_FEE); + } + + function setHarvestOnDeposit(bool _harvestOnDeposit) external onlyManager { + harvestOnDeposit = _harvestOnDeposit; + if (harvestOnDeposit) { + setWithdrawalFee(0); + } else { + setWithdrawalFee(10); + } + } + // called as part of strat migration. Sends all the available funds back to the vault. function retireStrat() external { require(msg.sender == vault, "!vault"); ILendingPool(lendingPool).withdraw(want, type(uint).max, address(this)); - uint256 wantBal = IERC20(want).balanceOf(address(this)); + uint256 wantBal = balanceOfWant(); IERC20(want).transfer(vault, wantBal); } @@ -188,11 +248,11 @@ contract StrategyAaveSupplyOnly is StratManager, FeeManager { function _giveAllowances() internal { IERC20(want).safeApprove(lendingPool, uint256(-1)); - IERC20(wmatic).safeApprove(unirouter, uint256(-1)); + IERC20(native).safeApprove(unirouter, uint256(-1)); } function _removeAllowances() internal { IERC20(want).safeApprove(lendingPool, 0); - IERC20(wmatic).safeApprove(unirouter, 0); + IERC20(native).safeApprove(unirouter, 0); } -} \ No newline at end of file +} \ No newline at end of file diff --git a/contracts/BIFI/strategies/Alpaca/StrategyAlpacaVault.sol b/contracts/archive/strategies/Alpaca/StrategyAlpacaVault.sol similarity index 100% rename from contracts/BIFI/strategies/Alpaca/StrategyAlpacaVault.sol rename to contracts/archive/strategies/Alpaca/StrategyAlpacaVault.sol diff --git a/contracts/BIFI/strategies/Ape/StrategyJungleChefLP.sol b/contracts/archive/strategies/Ape/StrategyJungleChefLP.sol similarity index 100% rename from contracts/BIFI/strategies/Ape/StrategyJungleChefLP.sol rename to contracts/archive/strategies/Ape/StrategyJungleChefLP.sol diff --git a/contracts/BIFI/strategies/Aurora/StrategyAuroraChefLP.sol b/contracts/archive/strategies/Aurora/StrategyAuroraChefLP.sol similarity index 100% rename from contracts/BIFI/strategies/Aurora/StrategyAuroraChefLP.sol rename to contracts/archive/strategies/Aurora/StrategyAuroraChefLP.sol diff --git a/contracts/BIFI/strategies/Aurora/StrategyRoseLP.sol b/contracts/archive/strategies/Aurora/StrategyRoseLP.sol similarity index 100% rename from contracts/BIFI/strategies/Aurora/StrategyRoseLP.sol rename to contracts/archive/strategies/Aurora/StrategyRoseLP.sol diff --git a/contracts/BIFI/strategies/Aurora/StrategyRoseUSTLP.sol b/contracts/archive/strategies/Aurora/StrategyRoseUSTLP.sol similarity index 100% rename from contracts/BIFI/strategies/Aurora/StrategyRoseUSTLP.sol rename to contracts/archive/strategies/Aurora/StrategyRoseUSTLP.sol diff --git a/contracts/BIFI/strategies/Aurora/StrategyTriMiniChefDualLP.sol b/contracts/archive/strategies/Aurora/StrategyTriMiniChefDualLP.sol similarity index 100% rename from contracts/BIFI/strategies/Aurora/StrategyTriMiniChefDualLP.sol rename to contracts/archive/strategies/Aurora/StrategyTriMiniChefDualLP.sol diff --git a/contracts/BIFI/strategies/Aurora/StrategyTriMiniChefDualStable.sol b/contracts/archive/strategies/Aurora/StrategyTriMiniChefDualStable.sol similarity index 100% rename from contracts/BIFI/strategies/Aurora/StrategyTriMiniChefDualStable.sol rename to contracts/archive/strategies/Aurora/StrategyTriMiniChefDualStable.sol diff --git a/contracts/BIFI/strategies/Aurora/StrategyTriMiniChefLP.sol b/contracts/archive/strategies/Aurora/StrategyTriMiniChefLP.sol similarity index 100% rename from contracts/BIFI/strategies/Aurora/StrategyTriMiniChefLP.sol rename to contracts/archive/strategies/Aurora/StrategyTriMiniChefLP.sol diff --git a/contracts/BIFI/strategies/BIFI/StrategyBifiMaxi.sol b/contracts/archive/strategies/BIFI/StrategyBifiMaxi.sol similarity index 100% rename from contracts/BIFI/strategies/BIFI/StrategyBifiMaxi.sol rename to contracts/archive/strategies/BIFI/StrategyBifiMaxi.sol diff --git a/contracts/BIFI/strategies/BIFI/StrategyBifiMaxiLowGas.sol b/contracts/archive/strategies/BIFI/StrategyBifiMaxiLowGas.sol similarity index 100% rename from contracts/BIFI/strategies/BIFI/StrategyBifiMaxiLowGas.sol rename to contracts/archive/strategies/BIFI/StrategyBifiMaxiLowGas.sol diff --git a/contracts/BIFI/strategies/BIFI/StrategyBifiMaxiV2.sol b/contracts/archive/strategies/BIFI/StrategyBifiMaxiV2.sol similarity index 100% rename from contracts/BIFI/strategies/BIFI/StrategyBifiMaxiV2.sol rename to contracts/archive/strategies/BIFI/StrategyBifiMaxiV2.sol diff --git a/contracts/BIFI/strategies/BIFI/StrategyBifiMaxiV3.sol b/contracts/archive/strategies/BIFI/StrategyBifiMaxiV3.sol similarity index 100% rename from contracts/BIFI/strategies/BIFI/StrategyBifiMaxiV3.sol rename to contracts/archive/strategies/BIFI/StrategyBifiMaxiV3.sol diff --git a/contracts/BIFI/strategies/BIFI/StrategyBifiMaxiV4.sol b/contracts/archive/strategies/BIFI/StrategyBifiMaxiV4.sol similarity index 100% rename from contracts/BIFI/strategies/BIFI/StrategyBifiMaxiV4.sol rename to contracts/archive/strategies/BIFI/StrategyBifiMaxiV4.sol diff --git a/contracts/BIFI/strategies/Beamswap/StrategyBeamswapStable.sol b/contracts/archive/strategies/Beamswap/StrategyBeamswapStable.sol similarity index 100% rename from contracts/BIFI/strategies/Beamswap/StrategyBeamswapStable.sol rename to contracts/archive/strategies/Beamswap/StrategyBeamswapStable.sol diff --git a/contracts/BIFI/strategies/Beethovenx/MaiStrategyBeethovenx.sol b/contracts/archive/strategies/Beethovenx/MaiStrategyBeethovenx.sol similarity index 100% rename from contracts/BIFI/strategies/Beethovenx/MaiStrategyBeethovenx.sol rename to contracts/archive/strategies/Beethovenx/MaiStrategyBeethovenx.sol diff --git a/contracts/BIFI/strategies/Beethovenx/StrategyBeethovenx.sol b/contracts/archive/strategies/Beethovenx/StrategyBeethovenx.sol similarity index 100% rename from contracts/BIFI/strategies/Beethovenx/StrategyBeethovenx.sol rename to contracts/archive/strategies/Beethovenx/StrategyBeethovenx.sol diff --git a/contracts/BIFI/strategies/Beethovenx/StrategyBeethovenxDual.sol b/contracts/archive/strategies/Beethovenx/StrategyBeethovenxDual.sol similarity index 100% rename from contracts/BIFI/strategies/Beethovenx/StrategyBeethovenxDual.sol rename to contracts/archive/strategies/Beethovenx/StrategyBeethovenxDual.sol diff --git a/contracts/BIFI/strategies/Beethovenx/StrategyBeethovenxDualTwoStep.sol b/contracts/archive/strategies/Beethovenx/StrategyBeethovenxDualTwoStep.sol similarity index 100% rename from contracts/BIFI/strategies/Beethovenx/StrategyBeethovenxDualTwoStep.sol rename to contracts/archive/strategies/Beethovenx/StrategyBeethovenxDualTwoStep.sol diff --git a/contracts/BIFI/strategies/Beethovenx/StrategyBeethovenxSpiritRouter.sol b/contracts/archive/strategies/Beethovenx/StrategyBeethovenxSpiritRouter.sol similarity index 100% rename from contracts/BIFI/strategies/Beethovenx/StrategyBeethovenxSpiritRouter.sol rename to contracts/archive/strategies/Beethovenx/StrategyBeethovenxSpiritRouter.sol diff --git a/contracts/BIFI/strategies/Beethovenx/StrategyBeethovenxUST.sol b/contracts/archive/strategies/Beethovenx/StrategyBeethovenxUST.sol similarity index 100% rename from contracts/BIFI/strategies/Beethovenx/StrategyBeethovenxUST.sol rename to contracts/archive/strategies/Beethovenx/StrategyBeethovenxUST.sol diff --git a/contracts/BIFI/strategies/Beethovenx/StrategyBeethovenxfBeets.sol b/contracts/archive/strategies/Beethovenx/StrategyBeethovenxfBeets.sol similarity index 100% rename from contracts/BIFI/strategies/Beethovenx/StrategyBeethovenxfBeets.sol rename to contracts/archive/strategies/Beethovenx/StrategyBeethovenxfBeets.sol diff --git a/contracts/BIFI/strategies/Belt/Strategy4Belt.sol b/contracts/archive/strategies/Belt/Strategy4Belt.sol similarity index 100% rename from contracts/BIFI/strategies/Belt/Strategy4Belt.sol rename to contracts/archive/strategies/Belt/Strategy4Belt.sol diff --git a/contracts/BIFI/strategies/Belt/StrategyBeltCakeLP.sol b/contracts/archive/strategies/Belt/StrategyBeltCakeLP.sol similarity index 100% rename from contracts/BIFI/strategies/Belt/StrategyBeltCakeLP.sol rename to contracts/archive/strategies/Belt/StrategyBeltCakeLP.sol diff --git a/contracts/BIFI/strategies/Belt/StrategyBeltToken.sol b/contracts/archive/strategies/Belt/StrategyBeltToken.sol similarity index 100% rename from contracts/BIFI/strategies/Belt/StrategyBeltToken.sol rename to contracts/archive/strategies/Belt/StrategyBeltToken.sol diff --git a/contracts/BIFI/strategies/Belt/StrategyBeltVenusBLP.sol b/contracts/archive/strategies/Belt/StrategyBeltVenusBLP.sol similarity index 100% rename from contracts/BIFI/strategies/Belt/StrategyBeltVenusBLP.sol rename to contracts/archive/strategies/Belt/StrategyBeltVenusBLP.sol diff --git a/contracts/BIFI/strategies/Biswap/StrategyBiswap.sol b/contracts/archive/strategies/Biswap/StrategyBiswap.sol similarity index 100% rename from contracts/BIFI/strategies/Biswap/StrategyBiswap.sol rename to contracts/archive/strategies/Biswap/StrategyBiswap.sol diff --git a/contracts/BIFI/strategies/Blizz/IBlizz.sol b/contracts/archive/strategies/Blizz/IBlizz.sol similarity index 100% rename from contracts/BIFI/strategies/Blizz/IBlizz.sol rename to contracts/archive/strategies/Blizz/IBlizz.sol diff --git a/contracts/BIFI/strategies/Blizz/StrategyBlizz.sol b/contracts/archive/strategies/Blizz/StrategyBlizz.sol similarity index 100% rename from contracts/BIFI/strategies/Blizz/StrategyBlizz.sol rename to contracts/archive/strategies/Blizz/StrategyBlizz.sol diff --git a/contracts/BIFI/strategies/Blizz/StrategyBlizzChefLP.sol b/contracts/archive/strategies/Blizz/StrategyBlizzChefLP.sol similarity index 100% rename from contracts/BIFI/strategies/Blizz/StrategyBlizzChefLP.sol rename to contracts/archive/strategies/Blizz/StrategyBlizzChefLP.sol diff --git a/contracts/BIFI/strategies/Blizz/StrategyBlizzNative.sol b/contracts/archive/strategies/Blizz/StrategyBlizzNative.sol similarity index 100% rename from contracts/BIFI/strategies/Blizz/StrategyBlizzNative.sol rename to contracts/archive/strategies/Blizz/StrategyBlizzNative.sol diff --git a/contracts/BIFI/strategies/Blizz/StrategyRadiantChefLP.sol b/contracts/archive/strategies/Blizz/StrategyRadiantChefLP.sol similarity index 100% rename from contracts/BIFI/strategies/Blizz/StrategyRadiantChefLP.sol rename to contracts/archive/strategies/Blizz/StrategyRadiantChefLP.sol diff --git a/contracts/BIFI/strategies/Blizz/StrategyValas.sol b/contracts/archive/strategies/Blizz/StrategyValas.sol similarity index 100% rename from contracts/BIFI/strategies/Blizz/StrategyValas.sol rename to contracts/archive/strategies/Blizz/StrategyValas.sol diff --git a/contracts/BIFI/strategies/Blizz/StrategyValasChefLP.sol b/contracts/archive/strategies/Blizz/StrategyValasChefLP.sol similarity index 100% rename from contracts/BIFI/strategies/Blizz/StrategyValasChefLP.sol rename to contracts/archive/strategies/Blizz/StrategyValasChefLP.sol diff --git a/contracts/BIFI/strategies/Cake/FeeManagerCake.sol b/contracts/archive/strategies/Cake/FeeManagerCake.sol similarity index 100% rename from contracts/BIFI/strategies/Cake/FeeManagerCake.sol rename to contracts/archive/strategies/Cake/FeeManagerCake.sol diff --git a/contracts/BIFI/strategies/Cake/ICakeChefV2.sol b/contracts/archive/strategies/Cake/ICakeChefV2.sol similarity index 100% rename from contracts/BIFI/strategies/Cake/ICakeChefV2.sol rename to contracts/archive/strategies/Cake/ICakeChefV2.sol diff --git a/contracts/BIFI/strategies/Cake/IVeCakeStaker.sol b/contracts/archive/strategies/Cake/IVeCakeStaker.sol similarity index 100% rename from contracts/BIFI/strategies/Cake/IVeCakeStaker.sol rename to contracts/archive/strategies/Cake/IVeCakeStaker.sol diff --git a/contracts/BIFI/strategies/Cake/StratManagerCake.sol b/contracts/archive/strategies/Cake/StratManagerCake.sol similarity index 100% rename from contracts/BIFI/strategies/Cake/StratManagerCake.sol rename to contracts/archive/strategies/Cake/StratManagerCake.sol diff --git a/contracts/BIFI/strategies/Cake/StrategyCakeBoostedLP.sol b/contracts/archive/strategies/Cake/StrategyCakeBoostedLP.sol similarity index 100% rename from contracts/BIFI/strategies/Cake/StrategyCakeBoostedLP.sol rename to contracts/archive/strategies/Cake/StrategyCakeBoostedLP.sol diff --git a/contracts/BIFI/strategies/Cake/StrategyCakeV2.sol b/contracts/archive/strategies/Cake/StrategyCakeV2.sol similarity index 100% rename from contracts/BIFI/strategies/Cake/StrategyCakeV2.sol rename to contracts/archive/strategies/Cake/StrategyCakeV2.sol diff --git a/contracts/BIFI/strategies/Cometh/StrategyMultiRewardsPolygonLP.sol b/contracts/archive/strategies/Cometh/StrategyMultiRewardsPolygonLP.sol similarity index 100% rename from contracts/BIFI/strategies/Cometh/StrategyMultiRewardsPolygonLP.sol rename to contracts/archive/strategies/Cometh/StrategyMultiRewardsPolygonLP.sol diff --git a/contracts/BIFI/strategies/Cometh/StrategyRewardPoolPolygonLP.sol b/contracts/archive/strategies/Cometh/StrategyRewardPoolPolygonLP.sol similarity index 100% rename from contracts/BIFI/strategies/Cometh/StrategyRewardPoolPolygonLP.sol rename to contracts/archive/strategies/Cometh/StrategyRewardPoolPolygonLP.sol diff --git a/contracts/BIFI/strategies/Common/BeefyLP.sol b/contracts/archive/strategies/Common/BeefyLP.sol similarity index 100% rename from contracts/BIFI/strategies/Common/BeefyLP.sol rename to contracts/archive/strategies/Common/BeefyLP.sol diff --git a/contracts/BIFI/strategies/Common/FeeManager.sol b/contracts/archive/strategies/Common/FeeManager.sol similarity index 100% rename from contracts/BIFI/strategies/Common/FeeManager.sol rename to contracts/archive/strategies/Common/FeeManager.sol diff --git a/contracts/BIFI/strategies/Common/StratManager.sol b/contracts/archive/strategies/Common/StratManager.sol similarity index 100% rename from contracts/BIFI/strategies/Common/StratManager.sol rename to contracts/archive/strategies/Common/StratManager.sol diff --git a/contracts/BIFI/strategies/Common/StrategyCommonChefLPKeeper.txt b/contracts/archive/strategies/Common/StrategyCommonChefLPKeeper.txt similarity index 100% rename from contracts/BIFI/strategies/Common/StrategyCommonChefLPKeeper.txt rename to contracts/archive/strategies/Common/StrategyCommonChefLPKeeper.txt diff --git a/contracts/BIFI/strategies/Common/StrategyCommonChefLPTax.sol b/contracts/archive/strategies/Common/StrategyCommonChefLPTax.sol similarity index 100% rename from contracts/BIFI/strategies/Common/StrategyCommonChefLPTax.sol rename to contracts/archive/strategies/Common/StrategyCommonChefLPTax.sol diff --git a/contracts/BIFI/strategies/Common/StrategyCommonChefLPVoter.txt b/contracts/archive/strategies/Common/StrategyCommonChefLPVoter.txt similarity index 100% rename from contracts/BIFI/strategies/Common/StrategyCommonChefLPVoter.txt rename to contracts/archive/strategies/Common/StrategyCommonChefLPVoter.txt diff --git a/contracts/BIFI/strategies/Common/StrategyCommonChefReferrerLP.sol b/contracts/archive/strategies/Common/StrategyCommonChefReferrerLP.sol similarity index 100% rename from contracts/BIFI/strategies/Common/StrategyCommonChefReferrerLP.sol rename to contracts/archive/strategies/Common/StrategyCommonChefReferrerLP.sol diff --git a/contracts/BIFI/strategies/Common/StrategyCommonChefReferrerLPBsc.sol b/contracts/archive/strategies/Common/StrategyCommonChefReferrerLPBsc.sol similarity index 100% rename from contracts/BIFI/strategies/Common/StrategyCommonChefReferrerLPBsc.sol rename to contracts/archive/strategies/Common/StrategyCommonChefReferrerLPBsc.sol diff --git a/contracts/BIFI/strategies/Common/StrategyCommonChefReferrerSingle.sol b/contracts/archive/strategies/Common/StrategyCommonChefReferrerSingle.sol similarity index 100% rename from contracts/BIFI/strategies/Common/StrategyCommonChefReferrerSingle.sol rename to contracts/archive/strategies/Common/StrategyCommonChefReferrerSingle.sol diff --git a/contracts/BIFI/strategies/Common/StrategyCommonChefStaking.sol b/contracts/archive/strategies/Common/StrategyCommonChefStaking.sol similarity index 100% rename from contracts/BIFI/strategies/Common/StrategyCommonChefStaking.sol rename to contracts/archive/strategies/Common/StrategyCommonChefStaking.sol diff --git a/contracts/BIFI/strategies/Common/StrategyCommonMultiRewardPoolLP.sol b/contracts/archive/strategies/Common/StrategyCommonMultiRewardPoolLP.sol similarity index 100% rename from contracts/BIFI/strategies/Common/StrategyCommonMultiRewardPoolLP.sol rename to contracts/archive/strategies/Common/StrategyCommonMultiRewardPoolLP.sol diff --git a/contracts/BIFI/strategies/Common/StrategyCommonRewardPool.sol b/contracts/archive/strategies/Common/StrategyCommonRewardPool.sol similarity index 100% rename from contracts/BIFI/strategies/Common/StrategyCommonRewardPool.sol rename to contracts/archive/strategies/Common/StrategyCommonRewardPool.sol diff --git a/contracts/BIFI/strategies/Common/StrategyMiniChefLP.sol b/contracts/archive/strategies/Common/StrategyMiniChefLP.sol similarity index 100% rename from contracts/BIFI/strategies/Common/StrategyMiniChefLP.sol rename to contracts/archive/strategies/Common/StrategyMiniChefLP.sol diff --git a/contracts/BIFI/strategies/Common/StrategyRewardPoolBsc.sol b/contracts/archive/strategies/Common/StrategyRewardPoolBsc.sol similarity index 100% rename from contracts/BIFI/strategies/Common/StrategyRewardPoolBsc.sol rename to contracts/archive/strategies/Common/StrategyRewardPoolBsc.sol diff --git a/contracts/BIFI/strategies/Common/StrategyVaultSeeder.txt b/contracts/archive/strategies/Common/StrategyVaultSeeder.txt similarity index 100% rename from contracts/BIFI/strategies/Common/StrategyVaultSeeder.txt rename to contracts/archive/strategies/Common/StrategyVaultSeeder.txt diff --git a/contracts/BIFI/strategies/Common/StrategyYieldLP.sol b/contracts/archive/strategies/Common/StrategyYieldLP.sol similarity index 100% rename from contracts/BIFI/strategies/Common/StrategyYieldLP.sol rename to contracts/archive/strategies/Common/StrategyYieldLP.sol diff --git a/contracts/BIFI/strategies/Common/StrategybeTokenRewardPool.sol b/contracts/archive/strategies/Common/StrategybeTokenRewardPool.sol similarity index 100% rename from contracts/BIFI/strategies/Common/StrategybeTokenRewardPool.sol rename to contracts/archive/strategies/Common/StrategybeTokenRewardPool.sol diff --git a/contracts/BIFI/strategies/Common/YieldBalancer.sol b/contracts/archive/strategies/Common/YieldBalancer.sol similarity index 100% rename from contracts/BIFI/strategies/Common/YieldBalancer.sol rename to contracts/archive/strategies/Common/YieldBalancer.sol diff --git a/contracts/BIFI/strategies/Curve/StrategyCurveHectorLP.sol b/contracts/archive/strategies/Curve/StrategyCurveHectorLP.sol similarity index 100% rename from contracts/BIFI/strategies/Curve/StrategyCurveHectorLP.sol rename to contracts/archive/strategies/Curve/StrategyCurveHectorLP.sol diff --git a/contracts/BIFI/strategies/Curve/StrategyCurveLPUniV3Router_sol6.txt b/contracts/archive/strategies/Curve/StrategyCurveLPUniV3Router_sol6.txt similarity index 100% rename from contracts/BIFI/strategies/Curve/StrategyCurveLPUniV3Router_sol6.txt rename to contracts/archive/strategies/Curve/StrategyCurveLPUniV3Router_sol6.txt diff --git a/contracts/BIFI/strategies/DCA/BeefyDCAStrategyUnirouter.sol b/contracts/archive/strategies/DCA/BeefyDCAStrategyUnirouter.sol similarity index 100% rename from contracts/BIFI/strategies/DCA/BeefyDCAStrategyUnirouter.sol rename to contracts/archive/strategies/DCA/BeefyDCAStrategyUnirouter.sol diff --git a/contracts/BIFI/strategies/DCA/BeefyDCAVaultBase.sol b/contracts/archive/strategies/DCA/BeefyDCAVaultBase.sol similarity index 100% rename from contracts/BIFI/strategies/DCA/BeefyDCAVaultBase.sol rename to contracts/archive/strategies/DCA/BeefyDCAVaultBase.sol diff --git a/contracts/BIFI/strategies/DCA/BeefyERC721Enumerable.sol b/contracts/archive/strategies/DCA/BeefyERC721Enumerable.sol similarity index 100% rename from contracts/BIFI/strategies/DCA/BeefyERC721Enumerable.sol rename to contracts/archive/strategies/DCA/BeefyERC721Enumerable.sol diff --git a/contracts/BIFI/strategies/DCA/IDCAStrategy.sol b/contracts/archive/strategies/DCA/IDCAStrategy.sol similarity index 100% rename from contracts/BIFI/strategies/DCA/IDCAStrategy.sol rename to contracts/archive/strategies/DCA/IDCAStrategy.sol diff --git a/contracts/BIFI/strategies/DCA/IDCAVault.sol b/contracts/archive/strategies/DCA/IDCAVault.sol similarity index 100% rename from contracts/BIFI/strategies/DCA/IDCAVault.sol rename to contracts/archive/strategies/DCA/IDCAVault.sol diff --git a/contracts/BIFI/strategies/DCA/IMooStrategy.sol b/contracts/archive/strategies/DCA/IMooStrategy.sol similarity index 100% rename from contracts/BIFI/strategies/DCA/IMooStrategy.sol rename to contracts/archive/strategies/DCA/IMooStrategy.sol diff --git a/contracts/BIFI/strategies/DCA/IMooVault.sol b/contracts/archive/strategies/DCA/IMooVault.sol similarity index 100% rename from contracts/BIFI/strategies/DCA/IMooVault.sol rename to contracts/archive/strategies/DCA/IMooVault.sol diff --git a/contracts/BIFI/strategies/DFYN/StrategyDFYNDualFarmRewardPoolLP.sol b/contracts/archive/strategies/DFYN/StrategyDFYNDualFarmRewardPoolLP.sol similarity index 100% rename from contracts/BIFI/strategies/DFYN/StrategyDFYNDualFarmRewardPoolLP.sol rename to contracts/archive/strategies/DFYN/StrategyDFYNDualFarmRewardPoolLP.sol diff --git a/contracts/BIFI/strategies/DFYN/StrategyDFYNRewardPoolLP.sol b/contracts/archive/strategies/DFYN/StrategyDFYNRewardPoolLP.sol similarity index 100% rename from contracts/BIFI/strategies/DFYN/StrategyDFYNRewardPoolLP.sol rename to contracts/archive/strategies/DFYN/StrategyDFYNRewardPoolLP.sol diff --git a/contracts/BIFI/strategies/Ellipsis/StrategyDotDotEllipsisFlat.txt b/contracts/archive/strategies/Ellipsis/StrategyDotDotEllipsisFlat.txt similarity index 100% rename from contracts/BIFI/strategies/Ellipsis/StrategyDotDotEllipsisFlat.txt rename to contracts/archive/strategies/Ellipsis/StrategyDotDotEllipsisFlat.txt diff --git a/contracts/BIFI/strategies/Geist/StrategyGeist.sol b/contracts/archive/strategies/Geist/StrategyGeist.sol similarity index 100% rename from contracts/BIFI/strategies/Geist/StrategyGeist.sol rename to contracts/archive/strategies/Geist/StrategyGeist.sol diff --git a/contracts/BIFI/strategies/Geist/StrategyGeistChefLP.sol b/contracts/archive/strategies/Geist/StrategyGeistChefLP.sol similarity index 100% rename from contracts/BIFI/strategies/Geist/StrategyGeistChefLP.sol rename to contracts/archive/strategies/Geist/StrategyGeistChefLP.sol diff --git a/contracts/BIFI/strategies/Geist/StrategyGeistNative.sol b/contracts/archive/strategies/Geist/StrategyGeistNative.sol similarity index 100% rename from contracts/BIFI/strategies/Geist/StrategyGeistNative.sol rename to contracts/archive/strategies/Geist/StrategyGeistNative.sol diff --git a/contracts/BIFI/strategies/Huckleberry/StrategyFinn.sol b/contracts/archive/strategies/Huckleberry/StrategyFinn.sol similarity index 100% rename from contracts/BIFI/strategies/Huckleberry/StrategyFinn.sol rename to contracts/archive/strategies/Huckleberry/StrategyFinn.sol diff --git a/contracts/BIFI/strategies/Mdex/StrategyMdexBscLP.sol b/contracts/archive/strategies/Mdex/StrategyMdexBscLP.sol similarity index 100% rename from contracts/BIFI/strategies/Mdex/StrategyMdexBscLP.sol rename to contracts/archive/strategies/Mdex/StrategyMdexBscLP.sol diff --git a/contracts/BIFI/strategies/Mdex/StrategyMdexChefLP.sol b/contracts/archive/strategies/Mdex/StrategyMdexChefLP.sol similarity index 100% rename from contracts/BIFI/strategies/Mdex/StrategyMdexChefLP.sol rename to contracts/archive/strategies/Mdex/StrategyMdexChefLP.sol diff --git a/contracts/BIFI/strategies/Mdex/StrategyMdexChefSingle.sol b/contracts/archive/strategies/Mdex/StrategyMdexChefSingle.sol similarity index 100% rename from contracts/BIFI/strategies/Mdex/StrategyMdexChefSingle.sol rename to contracts/archive/strategies/Mdex/StrategyMdexChefSingle.sol diff --git a/contracts/BIFI/strategies/Mdex/StrategyMdexLP.sol b/contracts/archive/strategies/Mdex/StrategyMdexLP.sol similarity index 100% rename from contracts/BIFI/strategies/Mdex/StrategyMdexLP.sol rename to contracts/archive/strategies/Mdex/StrategyMdexLP.sol diff --git a/contracts/BIFI/strategies/Moonbeam/StrategyBeamChefLP.sol b/contracts/archive/strategies/Moonbeam/StrategyBeamChefLP.sol similarity index 100% rename from contracts/BIFI/strategies/Moonbeam/StrategyBeamChefLP.sol rename to contracts/archive/strategies/Moonbeam/StrategyBeamChefLP.sol diff --git a/contracts/BIFI/strategies/Moonbeam/StrategyStella.sol b/contracts/archive/strategies/Moonbeam/StrategyStella.sol similarity index 100% rename from contracts/BIFI/strategies/Moonbeam/StrategyStella.sol rename to contracts/archive/strategies/Moonbeam/StrategyStella.sol diff --git a/contracts/BIFI/strategies/Netswap/INetswapChef.sol b/contracts/archive/strategies/Netswap/INetswapChef.sol similarity index 100% rename from contracts/BIFI/strategies/Netswap/INetswapChef.sol rename to contracts/archive/strategies/Netswap/INetswapChef.sol diff --git a/contracts/BIFI/strategies/Netswap/StrategyNetswapDualLP.sol b/contracts/archive/strategies/Netswap/StrategyNetswapDualLP.sol similarity index 100% rename from contracts/BIFI/strategies/Netswap/StrategyNetswapDualLP.sol rename to contracts/archive/strategies/Netswap/StrategyNetswapDualLP.sol diff --git a/contracts/BIFI/strategies/Scream/StrategyOXDxSCREAM.sol b/contracts/archive/strategies/Scream/StrategyOXDxSCREAM.sol similarity index 100% rename from contracts/BIFI/strategies/Scream/StrategyOXDxSCREAM.sol rename to contracts/archive/strategies/Scream/StrategyOXDxSCREAM.sol diff --git a/contracts/BIFI/strategies/Scream/StrategyScream.sol b/contracts/archive/strategies/Scream/StrategyScream.sol similarity index 100% rename from contracts/BIFI/strategies/Scream/StrategyScream.sol rename to contracts/archive/strategies/Scream/StrategyScream.sol diff --git a/contracts/BIFI/strategies/Scream/StrategyScreamFTM.sol b/contracts/archive/strategies/Scream/StrategyScreamFTM.sol similarity index 100% rename from contracts/BIFI/strategies/Scream/StrategyScreamFTM.sol rename to contracts/archive/strategies/Scream/StrategyScreamFTM.sol diff --git a/contracts/BIFI/strategies/Scream/StrategyScreamSupplyOnly.sol b/contracts/archive/strategies/Scream/StrategyScreamSupplyOnly.sol similarity index 100% rename from contracts/BIFI/strategies/Scream/StrategyScreamSupplyOnly.sol rename to contracts/archive/strategies/Scream/StrategyScreamSupplyOnly.sol diff --git a/contracts/BIFI/strategies/Scream/StrategyScreamSupplyOnlyFrax.sol b/contracts/archive/strategies/Scream/StrategyScreamSupplyOnlyFrax.sol similarity index 100% rename from contracts/BIFI/strategies/Scream/StrategyScreamSupplyOnlyFrax.sol rename to contracts/archive/strategies/Scream/StrategyScreamSupplyOnlyFrax.sol diff --git a/contracts/BIFI/strategies/Scream/StrategySteakHouseLP.sol b/contracts/archive/strategies/Scream/StrategySteakHouseLP.sol similarity index 100% rename from contracts/BIFI/strategies/Scream/StrategySteakHouseLP.sol rename to contracts/archive/strategies/Scream/StrategySteakHouseLP.sol diff --git a/contracts/BIFI/strategies/Solace/StrategySolaceRewardPool.sol b/contracts/archive/strategies/Solace/StrategySolaceRewardPool.sol similarity index 100% rename from contracts/BIFI/strategies/Solace/StrategySolaceRewardPool.sol rename to contracts/archive/strategies/Solace/StrategySolaceRewardPool.sol diff --git a/contracts/BIFI/strategies/Solace/StrategySolaceV2RewardPool.txt b/contracts/archive/strategies/Solace/StrategySolaceV2RewardPool.txt similarity index 100% rename from contracts/BIFI/strategies/Solace/StrategySolaceV2RewardPool.txt rename to contracts/archive/strategies/Solace/StrategySolaceV2RewardPool.txt diff --git a/contracts/BIFI/strategies/Solarbeam/StrategySolarbeam.sol b/contracts/archive/strategies/Solarbeam/StrategySolarbeam.sol similarity index 100% rename from contracts/BIFI/strategies/Solarbeam/StrategySolarbeam.sol rename to contracts/archive/strategies/Solarbeam/StrategySolarbeam.sol diff --git a/contracts/BIFI/strategies/Solidly/SolidyStaker.sol b/contracts/archive/strategies/Solidly/SolidyStaker.sol similarity index 100% rename from contracts/BIFI/strategies/Solidly/SolidyStaker.sol rename to contracts/archive/strategies/Solidly/SolidyStaker.sol diff --git a/contracts/BIFI/strategies/Spirit/StrategySpiritChefLP.sol b/contracts/archive/strategies/Spirit/StrategySpiritChefLP.sol similarity index 100% rename from contracts/BIFI/strategies/Spirit/StrategySpiritChefLP.sol rename to contracts/archive/strategies/Spirit/StrategySpiritChefLP.sol diff --git a/contracts/BIFI/strategies/Stargate/StrategyStargateStaking.sol b/contracts/archive/strategies/Stargate/StrategyStargateStaking.sol similarity index 100% rename from contracts/BIFI/strategies/Stargate/StrategyStargateStaking.sol rename to contracts/archive/strategies/Stargate/StrategyStargateStaking.sol diff --git a/contracts/BIFI/strategies/Sushi/StrategyArbSushiDualLP.sol b/contracts/archive/strategies/Sushi/StrategyArbSushiDualLP.sol similarity index 100% rename from contracts/BIFI/strategies/Sushi/StrategyArbSushiDualLP.sol rename to contracts/archive/strategies/Sushi/StrategyArbSushiDualLP.sol diff --git a/contracts/BIFI/strategies/Sushi/StrategyMrSushiLP.sol b/contracts/archive/strategies/Sushi/StrategyMrSushiLP.sol similarity index 100% rename from contracts/BIFI/strategies/Sushi/StrategyMrSushiLP.sol rename to contracts/archive/strategies/Sushi/StrategyMrSushiLP.sol diff --git a/contracts/BIFI/strategies/Sushi/StrategyPolygonSushiLP.sol b/contracts/archive/strategies/Sushi/StrategyPolygonSushiLP.sol similarity index 100% rename from contracts/BIFI/strategies/Sushi/StrategyPolygonSushiLP.sol rename to contracts/archive/strategies/Sushi/StrategyPolygonSushiLP.sol diff --git a/contracts/BIFI/strategies/Sushi/StrategyPolygonSushiOhmLP.sol b/contracts/archive/strategies/Sushi/StrategyPolygonSushiOhmLP.sol similarity index 100% rename from contracts/BIFI/strategies/Sushi/StrategyPolygonSushiOhmLP.sol rename to contracts/archive/strategies/Sushi/StrategyPolygonSushiOhmLP.sol diff --git a/contracts/BIFI/strategies/Sushi/StrategySushiLP.sol b/contracts/archive/strategies/Sushi/StrategySushiLP.sol similarity index 100% rename from contracts/BIFI/strategies/Sushi/StrategySushiLP.sol rename to contracts/archive/strategies/Sushi/StrategySushiLP.sol diff --git a/contracts/BIFI/strategies/Sushi/StrategySushiNativeDualLP.sol b/contracts/archive/strategies/Sushi/StrategySushiNativeDualLP.sol similarity index 100% rename from contracts/BIFI/strategies/Sushi/StrategySushiNativeDualLP.sol rename to contracts/archive/strategies/Sushi/StrategySushiNativeDualLP.sol diff --git a/contracts/BIFI/strategies/Tomb/StrategyTombTSHARE.sol b/contracts/archive/strategies/Tomb/StrategyTombTSHARE.sol similarity index 100% rename from contracts/BIFI/strategies/Tomb/StrategyTombTSHARE.sol rename to contracts/archive/strategies/Tomb/StrategyTombTSHARE.sol diff --git a/contracts/BIFI/strategies/TraderJoe/StrategyTraderJoeBoostedLP.sol b/contracts/archive/strategies/Trader Joe/StrategyTraderJoeBoostedLP.sol similarity index 100% rename from contracts/BIFI/strategies/TraderJoe/StrategyTraderJoeBoostedLP.sol rename to contracts/archive/strategies/Trader Joe/StrategyTraderJoeBoostedLP.sol diff --git a/contracts/BIFI/strategies/TraderJoe/StrategyTraderJoeDualLP.sol b/contracts/archive/strategies/Trader Joe/StrategyTraderJoeDualLP.sol similarity index 100% rename from contracts/BIFI/strategies/TraderJoe/StrategyTraderJoeDualLP.sol rename to contracts/archive/strategies/Trader Joe/StrategyTraderJoeDualLP.sol diff --git a/contracts/BIFI/strategies/TraderJoe/StrategyTraderJoeDualRouterNonNativeLP.sol b/contracts/archive/strategies/Trader Joe/StrategyTraderJoeDualRouterNonNativeLP.sol similarity index 100% rename from contracts/BIFI/strategies/TraderJoe/StrategyTraderJoeDualRouterNonNativeLP.sol rename to contracts/archive/strategies/Trader Joe/StrategyTraderJoeDualRouterNonNativeLP.sol diff --git a/contracts/BIFI/strategies/TraderJoe/StrategyTraderJoeSingleStake.sol b/contracts/archive/strategies/Trader Joe/StrategyTraderJoeSingleStake.sol similarity index 100% rename from contracts/BIFI/strategies/TraderJoe/StrategyTraderJoeSingleStake.sol rename to contracts/archive/strategies/Trader Joe/StrategyTraderJoeSingleStake.sol diff --git a/contracts/BIFI/strategies/VVS/StrategyVVSDualRewards.sol b/contracts/archive/strategies/VVS/StrategyVVSDualRewards.sol similarity index 100% rename from contracts/BIFI/strategies/VVS/StrategyVVSDualRewards.sol rename to contracts/archive/strategies/VVS/StrategyVVSDualRewards.sol diff --git a/contracts/BIFI/strategies/ValleySwap/StrategyValleySwapLP.sol b/contracts/archive/strategies/ValleySwap/StrategyValleySwapLP.sol similarity index 100% rename from contracts/BIFI/strategies/ValleySwap/StrategyValleySwapLP.sol rename to contracts/archive/strategies/ValleySwap/StrategyValleySwapLP.sol diff --git a/contracts/BIFI/strategies/Voltage/StrategyFuseRewardPoolLP.sol b/contracts/archive/strategies/Voltage/StrategyFuseRewardPoolLP.sol similarity index 100% rename from contracts/BIFI/strategies/Voltage/StrategyFuseRewardPoolLP.sol rename to contracts/archive/strategies/Voltage/StrategyFuseRewardPoolLP.sol diff --git a/contracts/BIFI/strategies/Voltage/StrategyVoltageStable.sol b/contracts/archive/strategies/Voltage/StrategyVoltageStable.sol similarity index 100% rename from contracts/BIFI/strategies/Voltage/StrategyVoltageStable.sol rename to contracts/archive/strategies/Voltage/StrategyVoltageStable.sol diff --git a/contracts/BIFI/strategies/Yuzu/StrategyYuzuChefMultiRewardsSwapMiningLP.sol b/contracts/archive/strategies/Yuzu/StrategyYuzuChefMultiRewardsSwapMiningLP.sol similarity index 100% rename from contracts/BIFI/strategies/Yuzu/StrategyYuzuChefMultiRewardsSwapMiningLP.sol rename to contracts/archive/strategies/Yuzu/StrategyYuzuChefMultiRewardsSwapMiningLP.sol diff --git a/contracts/BIFI/strategies/Yuzu/StrategyYuzuChefSwapMiningLP.sol b/contracts/archive/strategies/Yuzu/StrategyYuzuChefSwapMiningLP.sol similarity index 100% rename from contracts/BIFI/strategies/Yuzu/StrategyYuzuChefSwapMiningLP.sol rename to contracts/archive/strategies/Yuzu/StrategyYuzuChefSwapMiningLP.sol diff --git a/contracts/BIFI/strategies/Locked/beFTMRewardPool.sol b/contracts/archive/strategies/beFTMRewardPool.sol similarity index 100% rename from contracts/BIFI/strategies/Locked/beFTMRewardPool.sol rename to contracts/archive/strategies/beFTMRewardPool.sol diff --git a/contracts/BIFI/strategies/degens/LaunchpoolProxy.sol b/contracts/archive/strategies/degens/LaunchpoolProxy.sol similarity index 100% rename from contracts/BIFI/strategies/degens/LaunchpoolProxy.sol rename to contracts/archive/strategies/degens/LaunchpoolProxy.sol diff --git a/contracts/BIFI/strategies/degens/LaunchpoolReferralBsc.sol b/contracts/archive/strategies/degens/LaunchpoolReferralBsc.sol similarity index 100% rename from contracts/BIFI/strategies/degens/LaunchpoolReferralBsc.sol rename to contracts/archive/strategies/degens/LaunchpoolReferralBsc.sol diff --git a/contracts/BIFI/strategies/degens/LaunchpoolReferralFantom.sol b/contracts/archive/strategies/degens/LaunchpoolReferralFantom.sol similarity index 100% rename from contracts/BIFI/strategies/degens/LaunchpoolReferralFantom.sol rename to contracts/archive/strategies/degens/LaunchpoolReferralFantom.sol diff --git a/contracts/BIFI/strategies/degens/LaunchpoolReferralPolygon.sol b/contracts/archive/strategies/degens/LaunchpoolReferralPolygon.sol similarity index 100% rename from contracts/BIFI/strategies/degens/LaunchpoolReferralPolygon.sol rename to contracts/archive/strategies/degens/LaunchpoolReferralPolygon.sol diff --git a/contracts/BIFI/strategies/degens/StrategyAnnex.sol b/contracts/archive/strategies/degens/StrategyAnnex.sol similarity index 100% rename from contracts/BIFI/strategies/degens/StrategyAnnex.sol rename to contracts/archive/strategies/degens/StrategyAnnex.sol diff --git a/contracts/BIFI/strategies/degens/StrategyBanana.sol b/contracts/archive/strategies/degens/StrategyBanana.sol similarity index 100% rename from contracts/BIFI/strategies/degens/StrategyBanana.sol rename to contracts/archive/strategies/degens/StrategyBanana.sol diff --git a/contracts/BIFI/strategies/degens/StrategyBetu.sol b/contracts/archive/strategies/degens/StrategyBetu.sol similarity index 100% rename from contracts/BIFI/strategies/degens/StrategyBetu.sol rename to contracts/archive/strategies/degens/StrategyBetu.sol diff --git a/contracts/BIFI/strategies/degens/StrategyBison.sol b/contracts/archive/strategies/degens/StrategyBison.sol similarity index 100% rename from contracts/BIFI/strategies/degens/StrategyBison.sol rename to contracts/archive/strategies/degens/StrategyBison.sol diff --git a/contracts/BIFI/strategies/degens/StrategyChargeLP.sol b/contracts/archive/strategies/degens/StrategyChargeLP.sol similarity index 100% rename from contracts/BIFI/strategies/degens/StrategyChargeLP.sol rename to contracts/archive/strategies/degens/StrategyChargeLP.sol diff --git a/contracts/BIFI/strategies/degens/StrategyDinoSwapLP.sol b/contracts/archive/strategies/degens/StrategyDinoSwapLP.sol similarity index 100% rename from contracts/BIFI/strategies/degens/StrategyDinoSwapLP.sol rename to contracts/archive/strategies/degens/StrategyDinoSwapLP.sol diff --git a/contracts/BIFI/strategies/degens/StrategyDinoSwapSushiLP.sol b/contracts/archive/strategies/degens/StrategyDinoSwapSushiLP.sol similarity index 100% rename from contracts/BIFI/strategies/degens/StrategyDinoSwapSushiLP.sol rename to contracts/archive/strategies/degens/StrategyDinoSwapSushiLP.sol diff --git a/contracts/BIFI/strategies/degens/StrategyJetswapBusdLP.sol b/contracts/archive/strategies/degens/StrategyJetswapBusdLP.sol similarity index 100% rename from contracts/BIFI/strategies/degens/StrategyJetswapBusdLP.sol rename to contracts/archive/strategies/degens/StrategyJetswapBusdLP.sol diff --git a/contracts/BIFI/strategies/degens/StrategyJetswapLP.sol b/contracts/archive/strategies/degens/StrategyJetswapLP.sol similarity index 100% rename from contracts/BIFI/strategies/degens/StrategyJetswapLP.sol rename to contracts/archive/strategies/degens/StrategyJetswapLP.sol diff --git a/contracts/BIFI/strategies/degens/StrategyJetswapWings.sol b/contracts/archive/strategies/degens/StrategyJetswapWings.sol similarity index 100% rename from contracts/BIFI/strategies/degens/StrategyJetswapWings.sol rename to contracts/archive/strategies/degens/StrategyJetswapWings.sol diff --git a/contracts/BIFI/strategies/degens/StrategyLiquidus.sol b/contracts/archive/strategies/degens/StrategyLiquidus.sol similarity index 100% rename from contracts/BIFI/strategies/degens/StrategyLiquidus.sol rename to contracts/archive/strategies/degens/StrategyLiquidus.sol diff --git a/contracts/BIFI/strategies/degens/StrategyMasterChefApeLP.sol b/contracts/archive/strategies/degens/StrategyMasterChefApeLP.sol similarity index 100% rename from contracts/BIFI/strategies/degens/StrategyMasterChefApeLP.sol rename to contracts/archive/strategies/degens/StrategyMasterChefApeLP.sol diff --git a/contracts/BIFI/strategies/Spooky/StrategyMasterChefLP.sol b/contracts/archive/strategies/degens/StrategyMasterChefLP.sol similarity index 100% rename from contracts/BIFI/strategies/Spooky/StrategyMasterChefLP.sol rename to contracts/archive/strategies/degens/StrategyMasterChefLP.sol diff --git a/contracts/BIFI/strategies/degens/StrategyMasterChefPolygonLP.sol b/contracts/archive/strategies/degens/StrategyMasterChefPolygonLP.sol similarity index 100% rename from contracts/BIFI/strategies/degens/StrategyMasterChefPolygonLP.sol rename to contracts/archive/strategies/degens/StrategyMasterChefPolygonLP.sol diff --git a/contracts/BIFI/strategies/degens/StrategyMoonpotRewardPool.sol b/contracts/archive/strategies/degens/StrategyMoonpotRewardPool.sol similarity index 100% rename from contracts/BIFI/strategies/degens/StrategyMoonpotRewardPool.sol rename to contracts/archive/strategies/degens/StrategyMoonpotRewardPool.sol diff --git a/contracts/BIFI/strategies/degens/StrategyNfty.sol b/contracts/archive/strategies/degens/StrategyNfty.sol similarity index 100% rename from contracts/BIFI/strategies/degens/StrategyNfty.sol rename to contracts/archive/strategies/degens/StrategyNfty.sol diff --git a/contracts/BIFI/strategies/Spooky/StrategyOXDxBOO.sol b/contracts/archive/strategies/degens/StrategyOXDxBOO.sol similarity index 100% rename from contracts/BIFI/strategies/Spooky/StrategyOXDxBOO.sol rename to contracts/archive/strategies/degens/StrategyOXDxBOO.sol diff --git a/contracts/BIFI/strategies/Pangolin/StrategyPangolinLP.sol b/contracts/archive/strategies/degens/StrategyPangolinLP.sol similarity index 100% rename from contracts/BIFI/strategies/Pangolin/StrategyPangolinLP.sol rename to contracts/archive/strategies/degens/StrategyPangolinLP.sol diff --git a/contracts/BIFI/strategies/Pangolin/StrategyPangolinMiniChefLP.sol b/contracts/archive/strategies/degens/StrategyPangolinMiniChefLP.sol similarity index 100% rename from contracts/BIFI/strategies/Pangolin/StrategyPangolinMiniChefLP.sol rename to contracts/archive/strategies/degens/StrategyPangolinMiniChefLP.sol diff --git a/contracts/BIFI/strategies/Pangolin/StrategyPangolinMultiRewardsLP.sol b/contracts/archive/strategies/degens/StrategyPangolinMultiRewardsLP.sol similarity index 100% rename from contracts/BIFI/strategies/Pangolin/StrategyPangolinMultiRewardsLP.sol rename to contracts/archive/strategies/degens/StrategyPangolinMultiRewardsLP.sol diff --git a/contracts/BIFI/strategies/QuickSwap/StrategyPolygonQuickLP.sol b/contracts/archive/strategies/degens/StrategyPolygonQuickLP.sol similarity index 100% rename from contracts/BIFI/strategies/QuickSwap/StrategyPolygonQuickLP.sol rename to contracts/archive/strategies/degens/StrategyPolygonQuickLP.sol diff --git a/contracts/BIFI/strategies/QuickSwap/StrategyQuickDragonsLair.sol b/contracts/archive/strategies/degens/StrategyQuickDragonsLair.sol similarity index 100% rename from contracts/BIFI/strategies/QuickSwap/StrategyQuickDragonsLair.sol rename to contracts/archive/strategies/degens/StrategyQuickDragonsLair.sol diff --git a/contracts/BIFI/strategies/QuickSwap/StrategyQuickDualRewardLP.sol b/contracts/archive/strategies/degens/StrategyQuickDualRewardLP.sol similarity index 100% rename from contracts/BIFI/strategies/QuickSwap/StrategyQuickDualRewardLP.sol rename to contracts/archive/strategies/degens/StrategyQuickDualRewardLP.sol diff --git a/contracts/BIFI/strategies/QuickSwap/StrategyRewardPoolPolygonETHLP.sol b/contracts/archive/strategies/degens/StrategyRewardPoolPolygonETHLP.sol similarity index 100% rename from contracts/BIFI/strategies/QuickSwap/StrategyRewardPoolPolygonETHLP.sol rename to contracts/archive/strategies/degens/StrategyRewardPoolPolygonETHLP.sol diff --git a/contracts/BIFI/strategies/Solarbeam/StrategySolarbeamStable.sol b/contracts/archive/strategies/degens/StrategySolarbeamStable.sol similarity index 100% rename from contracts/BIFI/strategies/Solarbeam/StrategySolarbeamStable.sol rename to contracts/archive/strategies/degens/StrategySolarbeamStable.sol diff --git a/contracts/BIFI/strategies/Spooky/StrategySpookyV2LP.sol b/contracts/archive/strategies/degens/StrategySpookyV2LP.sol similarity index 100% rename from contracts/BIFI/strategies/Spooky/StrategySpookyV2LP.sol rename to contracts/archive/strategies/degens/StrategySpookyV2LP.sol diff --git a/contracts/BIFI/strategies/Stellaswap/StrategyStellaswapDualRewardLP.sol b/contracts/archive/strategies/degens/StrategyStellaswapDualRewardLP.sol similarity index 100% rename from contracts/BIFI/strategies/Stellaswap/StrategyStellaswapDualRewardLP.sol rename to contracts/archive/strategies/degens/StrategyStellaswapDualRewardLP.sol diff --git a/contracts/BIFI/strategies/Stellaswap/StrategyStellaswapStable.sol b/contracts/archive/strategies/degens/StrategyStellaswapStable.sol similarity index 100% rename from contracts/BIFI/strategies/Stellaswap/StrategyStellaswapStable.sol rename to contracts/archive/strategies/degens/StrategyStellaswapStable.sol diff --git a/contracts/BIFI/strategies/veJOE/ChefManager.sol b/contracts/archive/strategies/veJOE/ChefManager.sol similarity index 100% rename from contracts/BIFI/strategies/veJOE/ChefManager.sol rename to contracts/archive/strategies/veJOE/ChefManager.sol diff --git a/contracts/BIFI/strategies/veJOE/IJoeChef.sol b/contracts/archive/strategies/veJOE/IJoeChef.sol similarity index 100% rename from contracts/BIFI/strategies/veJOE/IJoeChef.sol rename to contracts/archive/strategies/veJOE/IJoeChef.sol diff --git a/contracts/BIFI/strategies/veJOE/IJoeStrategy.sol b/contracts/archive/strategies/veJOE/IJoeStrategy.sol similarity index 100% rename from contracts/BIFI/strategies/veJOE/IJoeStrategy.sol rename to contracts/archive/strategies/veJOE/IJoeStrategy.sol diff --git a/contracts/BIFI/strategies/veJOE/IVeJoe.sol b/contracts/archive/strategies/veJOE/IVeJoe.sol similarity index 100% rename from contracts/BIFI/strategies/veJOE/IVeJoe.sol rename to contracts/archive/strategies/veJOE/IVeJoe.sol diff --git a/contracts/BIFI/strategies/veJOE/JoeBatch.sol b/contracts/archive/strategies/veJOE/JoeBatch.sol similarity index 100% rename from contracts/BIFI/strategies/veJOE/JoeBatch.sol rename to contracts/archive/strategies/veJOE/JoeBatch.sol diff --git a/contracts/BIFI/strategies/veJOE/StrategyBeJoeRewardPool.sol b/contracts/archive/strategies/veJOE/StrategyBeJoeRewardPool.sol similarity index 100% rename from contracts/BIFI/strategies/veJOE/StrategyBeJoeRewardPool.sol rename to contracts/archive/strategies/veJOE/StrategyBeJoeRewardPool.sol diff --git a/contracts/BIFI/strategies/veJOE/VeJoeStaker.sol b/contracts/archive/strategies/veJOE/VeJoeStaker.sol similarity index 100% rename from contracts/BIFI/strategies/veJOE/VeJoeStaker.sol rename to contracts/archive/strategies/veJOE/VeJoeStaker.sol diff --git a/contracts/BIFI/utils/BeefyRefund.sol b/contracts/archive/utils/BeefyRefund.sol similarity index 100% rename from contracts/BIFI/utils/BeefyRefund.sol rename to contracts/archive/utils/BeefyRefund.sol diff --git a/contracts/BIFI/utils/BeefyRegistry.txt b/contracts/archive/utils/BeefyRegistry.txt similarity index 100% rename from contracts/BIFI/utils/BeefyRegistry.txt rename to contracts/archive/utils/BeefyRegistry.txt diff --git a/contracts/BIFI/utils/GasPrice.sol b/contracts/archive/utils/GasPrice.sol similarity index 100% rename from contracts/BIFI/utils/GasPrice.sol rename to contracts/archive/utils/GasPrice.sol diff --git a/contracts/BIFI/utils/GasThrottler.sol b/contracts/archive/utils/GasThrottler.sol similarity index 100% rename from contracts/BIFI/utils/GasThrottler.sol rename to contracts/archive/utils/GasThrottler.sol diff --git a/contracts/BIFI/utils/LPTokenWrapper.sol b/contracts/archive/utils/LPTokenWrapper.sol similarity index 100% rename from contracts/BIFI/utils/LPTokenWrapper.sol rename to contracts/archive/utils/LPTokenWrapper.sol diff --git a/contracts/BIFI/utils/Rescuer.sol b/contracts/archive/utils/Rescuer.sol similarity index 100% rename from contracts/BIFI/utils/Rescuer.sol rename to contracts/archive/utils/Rescuer.sol diff --git a/contracts/BIFI/utils/RescuerFrax.sol b/contracts/archive/utils/RescuerFrax.sol similarity index 100% rename from contracts/BIFI/utils/RescuerFrax.sol rename to contracts/archive/utils/RescuerFrax.sol diff --git a/contracts/BIFI/utils/RewardRecover.sol b/contracts/archive/utils/RewardRecover.sol similarity index 100% rename from contracts/BIFI/utils/RewardRecover.sol rename to contracts/archive/utils/RewardRecover.sol diff --git a/contracts/BIFI/utils/StrategistBuyback.sol b/contracts/archive/utils/StrategistBuyback.sol similarity index 100% rename from contracts/BIFI/utils/StrategistBuyback.sol rename to contracts/archive/utils/StrategistBuyback.sol diff --git a/contracts/BIFI/vaults/BeefyVaultV6.sol b/contracts/archive/vaults/BeefyVaultV6.sol similarity index 100% rename from contracts/BIFI/vaults/BeefyVaultV6.sol rename to contracts/archive/vaults/BeefyVaultV6.sol diff --git a/contracts/BIFI/vaults/BeefyVaultV6Native.sol b/contracts/archive/vaults/BeefyVaultV6Native.sol similarity index 100% rename from contracts/BIFI/vaults/BeefyVaultV6Native.sol rename to contracts/archive/vaults/BeefyVaultV6Native.sol diff --git a/contracts/BIFI/vaults/BeefyVaultv6Moonpot.sol b/contracts/archive/vaults/BeefyVaultv6Moonpot.sol similarity index 100% rename from contracts/BIFI/vaults/BeefyVaultv6Moonpot.sol rename to contracts/archive/vaults/BeefyVaultv6Moonpot.sol diff --git a/contracts/BIFI/zaps/BeefyPairFeeDataSource.sol b/contracts/archive/zaps/BeefyPairFeeDataSource.sol similarity index 100% rename from contracts/BIFI/zaps/BeefyPairFeeDataSource.sol rename to contracts/archive/zaps/BeefyPairFeeDataSource.sol diff --git a/contracts/BIFI/zaps/BeefyUniV2ZapSolidly.sol b/contracts/archive/zaps/BeefyUniV2ZapSolidly.sol similarity index 100% rename from contracts/BIFI/zaps/BeefyUniV2ZapSolidly.sol rename to contracts/archive/zaps/BeefyUniV2ZapSolidly.sol diff --git a/contracts/BIFI/zaps/BeefyZapMdex.sol b/contracts/archive/zaps/BeefyZapMdex.sol similarity index 100% rename from contracts/BIFI/zaps/BeefyZapMdex.sol rename to contracts/archive/zaps/BeefyZapMdex.sol diff --git a/contracts/BIFI/zaps/BeefyZapSolidlyDyst.sol b/contracts/archive/zaps/BeefyZapSolidlyDyst.sol similarity index 100% rename from contracts/BIFI/zaps/BeefyZapSolidlyDyst.sol rename to contracts/archive/zaps/BeefyZapSolidlyDyst.sol diff --git a/contracts/BIFI/zaps/BeefyZapUniswapV2.txt b/contracts/archive/zaps/BeefyZapUniswapV2.txt similarity index 100% rename from contracts/BIFI/zaps/BeefyZapUniswapV2.txt rename to contracts/archive/zaps/BeefyZapUniswapV2.txt diff --git a/contracts/BIFI/zaps/zapInterfaces/IBeefyDataSource.sol b/contracts/archive/zaps/IBeefyDataSource.sol similarity index 100% rename from contracts/BIFI/zaps/zapInterfaces/IBeefyDataSource.sol rename to contracts/archive/zaps/IBeefyDataSource.sol diff --git a/contracts/BIFI/zaps/ZapBeFtmOneInch.sol b/contracts/archive/zaps/ZapBeFtmOneInch.sol similarity index 100% rename from contracts/BIFI/zaps/ZapBeFtmOneInch.sol rename to contracts/archive/zaps/ZapBeFtmOneInch.sol diff --git a/contracts/BIFI/zaps/ZapBeVelo.sol b/contracts/archive/zaps/ZapBeVelo.sol similarity index 100% rename from contracts/BIFI/zaps/ZapBeVelo.sol rename to contracts/archive/zaps/ZapBeVelo.sol diff --git a/forge/test/strategy/StrategyAuraGyro.t.sol b/forge/test/strategy/StrategyAuraGyro.t.sol new file mode 100644 index 00000000..0a4e5d95 --- /dev/null +++ b/forge/test/strategy/StrategyAuraGyro.t.sol @@ -0,0 +1,211 @@ +//import "forge-std/Test.sol"; +pragma solidity ^0.8.0; + +import "../../../node_modules/forge-std/src/Test.sol"; + +import "../interfaces/IVault.sol"; +import "../interfaces/IStrategy.sol"; +import "../../../contracts/BIFI/vaults/BeefyVaultV7.sol"; +import "../../../contracts/BIFI/strategies/Balancer/StrategyAuraGyroMainnet.sol"; +import "../../../contracts/BIFI/strategies/Balancer/BeefyBalancerStructs.sol"; +import "../../../contracts/BIFI/strategies/Common/StratFeeManager.sol"; + +contract StrategyAuraGyroTest is Test { + + BeefyVaultV7 vault; + StrategyAuraGyroMainnet strategy; + + struct CommonAddresses { + address vault; + address unirouter; + address keeper; + address strategist; + address beefyFeeRecipient; + address beefyFeeConfig; + } + + address user = 0x161D61e30284A33Ab1ed227beDcac6014877B3DE; + address keeper = 0x4fED5491693007f0CD49f4614FFC38Ab6A04B619; + address feeRecipient = 0x8237f3992526036787E8178Def36291Ab94638CD; + address feeConfig = 0x3d38BA27974410679afF73abD096D7Ba58870EAd; + + address want = 0xf01b0684C98CD7aDA480BFDF6e43876422fa1Fc1; + address lp0 = 0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0; + address lp1 = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; + address booster = 0xA57b8d98dAE62B26Ec3bcC4a365338157060B234; + address router = 0xBA12222222228d8Ba445958a75a0704d566BF2C8; + address native = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; + address bal = 0xba100000625a3754423978a60c9317c58a424e3D; + address aura = 0xC0c293ce456fF0ED870ADd98a0828Dd4d2903DBF; + + uint256 pid = 162; + + error PPFS_NOT_INCREASED(); + + function routes() public view returns ( + BeefyBalancerStructs.BatchSwapStruct[] memory _outputToNativeRoute, + BeefyBalancerStructs.BatchSwapStruct[] memory _nativeToLp0Route, + BeefyBalancerStructs.BatchSwapStruct[] memory _lp0ToLp1Route, + BeefyBalancerStructs.BatchSwapStruct[] memory _auraToNativeRoute, + address[] memory _outputToNativeAssests, + address[] memory _nativeToLp0Assests, + address[] memory _lp0ToLp1Assests, + address[] memory _auraToNativeAssests + ) { + _outputToNativeRoute = new BeefyBalancerStructs.BatchSwapStruct[](1); + _outputToNativeRoute[0] = BeefyBalancerStructs.BatchSwapStruct({ + poolId: 0x5c6ee304399dbdb9c8ef030ab642b10820db8f56000200000000000000000014, + assetInIndex: 0, + assetOutIndex: 1 + }); + + _nativeToLp0Route = new BeefyBalancerStructs.BatchSwapStruct[](1); + _nativeToLp0Route[0] = BeefyBalancerStructs.BatchSwapStruct({ + poolId: 0x93d199263632a4ef4bb438f1feb99e57b4b5f0bd0000000000000000000005c2, + assetInIndex: 0, + assetOutIndex: 1 + }); + + _lp0ToLp1Route = new BeefyBalancerStructs.BatchSwapStruct[](1); + _lp0ToLp1Route[0] = BeefyBalancerStructs.BatchSwapStruct({ + poolId: 0x93d199263632a4ef4bb438f1feb99e57b4b5f0bd0000000000000000000005c2, + assetInIndex: 0, + assetOutIndex: 1 + }); + + _auraToNativeRoute = new BeefyBalancerStructs.BatchSwapStruct[](1); + _auraToNativeRoute[0] = BeefyBalancerStructs.BatchSwapStruct({ + poolId: 0xc29562b045d80fd77c69bec09541f5c16fe20d9d000200000000000000000251, + assetInIndex: 0, + assetOutIndex: 1 + }); + + _outputToNativeAssests = new address[](2); + _outputToNativeAssests[0] = bal; + _outputToNativeAssests[1] = native; + + _nativeToLp0Assests = new address[](2); + _nativeToLp0Assests[0] = native; + _nativeToLp0Assests[1] = lp0; + + _lp0ToLp1Assests = new address[](2); + _lp0ToLp1Assests[0] = lp0; + _lp0ToLp1Assests[1] = lp1; + + _auraToNativeAssests = new address[](2); + _auraToNativeAssests[0] = aura; + _auraToNativeAssests[1] = native; + } + + function setUp() public { + vault = new BeefyVaultV7(); + strategy = new StrategyAuraGyroMainnet(); + + ( + BeefyBalancerStructs.BatchSwapStruct[] memory _outputToNativeRoute, + BeefyBalancerStructs.BatchSwapStruct[] memory _nativeToLp0Route, + BeefyBalancerStructs.BatchSwapStruct[] memory _lp0ToLp1Route, + BeefyBalancerStructs.BatchSwapStruct[] memory _auraToNativeRoute, + address[] memory _outputToNativeAssests, + address[] memory _nativeToLp0Assests, + address[] memory _lp0ToLp1Assests, + address[] memory _auraToNativeAssests + ) = routes(); + + StratFeeManagerInitializable.CommonAddresses memory commonAddresses = StratFeeManagerInitializable.CommonAddresses({ + vault: address(vault), + unirouter: router, + keeper: keeper, + strategist: user, + beefyFeeRecipient: feeRecipient, + beefyFeeConfig: feeConfig + }); + + vault.initialize(IStrategyV7(address(strategy)), "MooTest", "mooTest", 0); + strategy.initialize( + want, + _nativeToLp0Route, + _lp0ToLp1Route, + _outputToNativeRoute, + booster, + pid, + _nativeToLp0Assests, + _lp0ToLp1Assests, + _outputToNativeAssests, + commonAddresses + ); + + strategy.addRewardToken(aura, _auraToNativeRoute, _auraToNativeAssests, bytes("0x"), 0); + strategy.setWithdrawalFee(0); + } + + function test_depositAndWithdraw() public { + vm.startPrank(user); + + deal(want, user, 10 ether); + + IERC20(want).approve(address(vault), 10 ether); + vault.deposit(10 ether); + + assertEq(IERC20(want).balanceOf(address(user)), 0); + + vault.withdraw(10 ether); + + assertEq(IERC20(want).balanceOf(address(user)), 10 ether); + vm.stopPrank(); + } + + function test_harvest() public { + vm.startPrank(user); + + deal(want, user, 10 ether); + + IERC20(want).approve(address(vault), 10 ether); + vault.deposit(10 ether); + + uint256 ppfs = vault.getPricePerFullShare(); + skip(1 days); + + strategy.harvest(); + + skip(1 minutes); + uint256 afterPpfs = vault.getPricePerFullShare(); + + if (afterPpfs <= ppfs) revert PPFS_NOT_INCREASED(); + vm.stopPrank(); + } + + function test_panic() public { + vm.startPrank(user); + + deal(want, user, 10 ether); + + IERC20(want).approve(address(vault), 10 ether); + vault.deposit(10 ether); + + vm.stopPrank(); + vm.startPrank(keeper); + + strategy.panic(); + + vm.stopPrank(); + vm.startPrank(user); + + vault.withdraw(5 ether); + + vm.expectRevert(); + vault.deposit(5 ether); + + vm.stopPrank(); + + vm.startPrank(keeper); + + strategy.unpause(); + + skip(1 days); + + strategy.harvest(); + + vm.stopPrank(); + } +} diff --git a/hardhat.config.ts b/hardhat.config.ts index f618238e..1ce839cb 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -161,6 +161,7 @@ const config: DeploymentConfig = { // Your API key for Etherscan // Obtain one at https://etherscan.io/ apiKey: { + mainnet: process.env.MAINNET_API_KEY!, polygon: process.env.POLYGON_API_KEY!, zkevm: process.env.ZKEVM_API_KEY!, bsc: process.env.BSC_API_KEY!, @@ -212,34 +213,7 @@ const config: DeploymentConfig = { runs: 200, }, }, - }, - { - version: "0.8.15", - settings: { - optimizer: { - enabled: true, - runs: 200, - }, - }, - }, - { - version: "0.6.12", - settings: { - optimizer: { - enabled: true, - runs: 200, - }, - }, - }, - { - version: "0.5.5", - settings: { - optimizer: { - enabled: true, - runs: 200, - }, - }, - }, + } ], }, paths: { diff --git a/package.json b/package.json index bbfb603b..23e2858d 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "test:harvester": "hardhat test --network localhost test/infra/BeefyAutoHarvester.test.ts", "deploy:chef": "hardhat run scripts/vault/deploy-generic-chef-strat.ts --network", "deploy:balancer": "hardhat run scripts/vault/deploy-balancer-strat-type.ts --network", + "deploy:aura": "hardhat run scripts/vault/deploy-balancer-strat-eth.ts --network", "deploy:bifiMaxi": "hardhat run scripts/vault/deploy-bifi-maxi.js --network", "deploy:curve": "hardhat run scripts/vault/deploy-curve-strat.ts --network", "deploy:rewardPool": "hardhat run scripts/vault/deploy-generic-rewardPool-strat.ts --network", @@ -56,6 +57,7 @@ "installForge": ". scripts/forge/installForge.sh", "forgeTest:vault": "forge test --force --fork-url https://rpc.ftm.tools --match-contract ProdVaultTest", "forgeTest:wrapper": "forge test --force --fork-url https://arb1.arbitrum.io/rpc --match-contract WrapperTest", + "forgeTest:aura": "forge test --force --fork-url https://rpc.ankr.com/eth --match-contract StrategyAuraGyroTest", "deploy:vaultFactory": "hardhat run scripts/deploy-vault-proxyFactory.js --network", "fork:bsc": "hardhat node --fork bsc", "deploy:tutorial": "hardhat run tutorials/deploy-pancakeswap-vault.js --network localhost" @@ -68,7 +70,6 @@ "@nomiclabs/hardhat-web3": "^2.0.0", "@openzeppelin-2/contracts": "npm:@openzeppelin/contracts@2.5.1", "@openzeppelin-4/contracts": "npm:@openzeppelin/contracts", - "@openzeppelin/contracts": "^3.4.2", "@openzeppelin/contracts-upgradeable": "^4.9.3", "@openzeppelin/hardhat-upgrades": "^1.21.0", "@openzeppelin/upgrades-core": "^1.20.4", diff --git a/scripts/infra/deployContract.js b/scripts/infra/deployContract.js index 7a62421b..be64d573 100644 --- a/scripts/infra/deployContract.js +++ b/scripts/infra/deployContract.js @@ -4,7 +4,7 @@ const { startingEtherPerAccount } = require("../../utils/configInit"); const ethers = hardhat.ethers; -const contractName = "StrategyQuickGamma"; +const contractName = "StrategyAuraGyroMainnet"; const factoryName = "BeefyVaultV7Factory"; const config = {}; diff --git a/scripts/vault/deploy-balancer-strat-eth.ts b/scripts/vault/deploy-balancer-strat-eth.ts index d8affc1a..8f3b4c13 100644 --- a/scripts/vault/deploy-balancer-strat-eth.ts +++ b/scripts/vault/deploy-balancer-strat-eth.ts @@ -2,38 +2,36 @@ import hardhat, { ethers, web3 } from "hardhat"; import { addressBook } from "blockchain-addressbook"; import vaultV7 from "../../artifacts/contracts/BIFI/vaults/BeefyVaultV7.sol/BeefyVaultV7.json"; import vaultV7Factory from "../../artifacts/contracts/BIFI/vaults/BeefyVaultV7Factory.sol/BeefyVaultV7Factory.json"; -import stratAbi from "../../artifacts/contracts/BIFI/strategies/Balancer/StrategyAuraBalancerMultiRewardGaugeUniV3.sol/StrategyAuraBalancerMultiRewardGaugeUniV3.json"; +import stratAbi from "../../artifacts/contracts/BIFI/strategies/Balancer/StrategyAuraGyroMainnet.sol/StrategyAuraGyroMainnet.json"; const { platforms: { balancer, beefyfinance }, tokens: { BAL: { address: BAL }, ETH: { address: ETH }, - bbaUSDC: { address: bbaUSDC }, - bbaUSD: { address: bbaUSD }, - USDC: { address: USDC }, - MAI: { address: MAI }, + cbETH: { address: cbETH }, + wstETH: { address: wstETH }, AURA: { address: AURA }, - rETH: { address: rETH }, + }, } = addressBook.ethereum; const bytes0 = '0x0000000000000000000000000000000000000000000000000000000000000000'; -const booster = web3.utils.toChecksumAddress("0x7818A1DA7BD1E64c199029E86Ba244a9798eEE10"); -const want = web3.utils.toChecksumAddress("0x334C96d792e4b26B841d28f53235281cec1be1F2"); +const booster = web3.utils.toChecksumAddress("0xA57b8d98dAE62B26Ec3bcC4a365338157060B234"); +const want = web3.utils.toChecksumAddress("0xf01b0684C98CD7aDA480BFDF6e43876422fa1Fc1"); const vaultParams = { - mooName: "Moo Aura rETH-bbaUSD", - mooSymbol: "mooAurarETH-bbaUSD", + mooName: "Moo Aura Gyro wstETH-ETH", + mooSymbol: "mooAuraGyrowstETH-ETH", delay: 21600, }; const strategyParams = { want: want, booster: booster, - pid: 52, - input: rETH, + pid: 162, + input: wstETH, isComposable: false, unirouter: balancer.router, strategist: process.env.STRATEGIST_ADDRESS, @@ -41,7 +39,7 @@ const strategyParams = { beefyFeeRecipient: beefyfinance.beefyFeeRecipient, beefyFeeConfig: beefyfinance.beefyFeeConfig, beefyVaultProxy: "0xC551dDCE8e5E657503Cd67A39713c06F2c0d2e97", //beefyfinance.vaultProxy, - strategyImplementation: "0xc0fbb8F79e6AB8cB0dCE77359748517F9DF1FE19", + strategyImplementation: "0x2b494952C10632B11fEf3139C38fE2AD939F4243", useVaultProxy: true, outputToNativeAssets: [ BAL, @@ -54,17 +52,28 @@ const strategyParams = { 1 ] ], - nativeToWantAssets: [ + nativeToLp0Assets: [ ETH, - rETH + wstETH ], - nativeToWantRouteBytes: [ + nativeToLp0RouteBytes: [ [ - "0x1e19cf2d73a72ef1332c882f20534b6519be0276000200000000000000000112", + "0x93d199263632a4ef4bb438f1feb99e57b4b5f0bd0000000000000000000005c2", 0, 1 ] ], + lp0ToLp1Assets: [ + wstETH, + ETH + ], + lp0ToLp1RouteBytes: [ + [ + "0x93d199263632a4ef4bb438f1feb99e57b4b5f0bd0000000000000000000005c2", + 0, + 1 + ] + ], auraToNativeAssets: [AURA, ETH], auraToNativePath: [ [ @@ -125,12 +134,13 @@ async function main() { const strategyConstructorArguments = [ strategyParams.want, - strategyParams.isComposable, - strategyParams.nativeToWantRouteBytes, + strategyParams.nativeToLp0RouteBytes, + strategyParams.lp0ToLp1RouteBytes, strategyParams.outputToNativeRouteBytes, strategyParams.booster, strategyParams.pid, - strategyParams.nativeToWantAssets, + strategyParams.nativeToLp0Assets, + strategyParams.lp0ToLp1Assets, strategyParams.outputToNativeAssets, [vault, strategyParams.unirouter, diff --git a/yarn.lock b/yarn.lock index fd17cb72..6fa8170d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -837,11 +837,6 @@ resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-3.4.2-solc-0.7.tgz#38f4dbab672631034076ccdf2f3201fab1726635" integrity sha512-W6QmqgkADuFcTLzHL8vVoNBtkwjvQRpYIAom7KiUNoLKghyx3FgH0GBjt8NRvigV1ZmMOBllvE1By1C+bi8WpA== -"@openzeppelin/contracts@^3.4.2": - version "3.4.2" - resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-3.4.2.tgz#d81f786fda2871d1eb8a8c5a73e455753ba53527" - integrity sha512-z0zMCjyhhp4y7XKAcDAi3Vgms4T2PstwBdahiO0+9NaGICQKjynK3wduSRplTgk4LXmoO1yfDGO5RbjKYxtuxA== - "@openzeppelin/hardhat-upgrades@^1.21.0": version "1.21.0" resolved "https://registry.yarnpkg.com/@openzeppelin/hardhat-upgrades/-/hardhat-upgrades-1.21.0.tgz#e90fb7d858093f35a300b3a5a2fd32bca6179dfc"