Skip to content

Commit

Permalink
VaultFactory: remove insurance; StrategyBaseV3: remove performanceFee…
Browse files Browse the repository at this point in the history
…Ratio; fixes
  • Loading branch information
a17 committed Jul 3, 2024
1 parent b1f84d8 commit e6eecb4
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 307 deletions.
4 changes: 1 addition & 3 deletions contracts/interfaces/IStrategyV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ interface IStrategyV3 is IStrategyV2 {
/// @dev {DEFAULT_PERFORMANCE_FEE} by default, FEE_DENOMINATOR is used
uint performanceFee;

/// @notice Ratio to split performance fee on toPerf + toInsurance, [0..100_000]
/// 100_000 - send full amount toPerf, 0 - send full amount toInsurance.
uint performanceFeeRatio;
uint __deprecated;

/// @dev Percent of profit for autocompound inside this strategy.
uint compoundRatio;
Expand Down
15 changes: 0 additions & 15 deletions contracts/interfaces/IVaultInsurance.sol

This file was deleted.

1 change: 0 additions & 1 deletion contracts/lib/InterfaceIds.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ library InterfaceIds {
bytes4 public constant I_PLATFORM_VOTER = bytes4(keccak256("IPlatformVoter"));
bytes4 public constant I_VE_DISTRIBUTOR = bytes4(keccak256("IVeDistributor"));
bytes4 public constant I_TETU_CONVERTER = bytes4(keccak256("ITetuConverter"));
bytes4 public constant I_VAULT_INSURANCE = bytes4(keccak256("IVaultInsurance"));
bytes4 public constant I_STRATEGY_STRICT = bytes4(keccak256("IStrategyStrict"));
bytes4 public constant I_ERC4626 = bytes4(keccak256("IERC4626"));

Expand Down
8 changes: 2 additions & 6 deletions contracts/strategy/StrategyBaseV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@ abstract contract StrategyBaseV3 is IStrategyV3, ControllableV3 {
return baseState.performanceFee;
}

function performanceFeeRatio() external view returns (uint) {
return baseState.performanceFeeRatio;
}

function strategySpecificName() external view returns (string memory) {
return baseState.strategySpecificName;
}
Expand Down Expand Up @@ -122,8 +118,8 @@ abstract contract StrategyBaseV3 is IStrategyV3, ControllableV3 {
// *************************************************************

/// @notice Set performance fee, receiver and ratio
function setupPerformanceFee(uint fee_, address receiver_, uint ratio_) external {
StrategyLib2.setupPerformanceFee(baseState, fee_, receiver_, ratio_, controller());
function setupPerformanceFee(uint fee_, address receiver_) external {
StrategyLib2.setupPerformanceFee(baseState, fee_, receiver_, controller());
}

// *************************************************************
Expand Down
12 changes: 5 additions & 7 deletions contracts/strategy/StrategyLib2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ library StrategyLib2 {
event InvestAll(uint balance);
event WithdrawAllToSplitter(uint amount);
event WithdrawToSplitter(uint amount, uint sent, uint balance);
event PerformanceFeeChanged(uint fee, address receiver, uint ratio);
event PerformanceFeeChanged(uint fee, address receiver);

// *************************************************************
// CHECKS AND EMITS
Expand All @@ -60,12 +60,11 @@ library StrategyLib2 {
emit InvestAll(assetBalance);
}

function _checkSetupPerformanceFee(address controller, uint fee_, address receiver_, uint ratio_) internal {
function _checkSetupPerformanceFee(address controller, uint fee_, address receiver_) internal {
onlyGovernance(controller);
require(fee_ <= DENOMINATOR, TOO_HIGH);
require(receiver_ != address(0), WRONG_VALUE);
require(ratio_ <= DENOMINATOR, TOO_HIGH);
emit PerformanceFeeChanged(fee_, receiver_, ratio_);
emit PerformanceFeeChanged(fee_, receiver_);
}

// *************************************************************
Expand Down Expand Up @@ -128,11 +127,10 @@ library StrategyLib2 {
require(IControllable(splitter_).isController(controller_), WRONG_VALUE);
}

function setupPerformanceFee(IStrategyV3.BaseState storage baseState, uint fee_, address receiver_, uint ratio_, address controller_) external {
_checkSetupPerformanceFee(controller_, fee_, receiver_, ratio_);
function setupPerformanceFee(IStrategyV3.BaseState storage baseState, uint fee_, address receiver_, address controller_) external {
_checkSetupPerformanceFee(controller_, fee_, receiver_);
baseState.performanceFee = fee_;
baseState.performanceReceiver = receiver_;
baseState.performanceFeeRatio = ratio_;
}

/// @notice Calculate withdrawn amount in USD using the {assetPrice}.
Expand Down
9 changes: 4 additions & 5 deletions contracts/vault/StrategySplitterV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@ contract StrategySplitterV2 is ControllableV3, ReentrancyGuard, ISplitter {
delete isValidStrategy[strategy];

// for expensive strategies should be called before removing
// without loss covering
IStrategyV2(strategy).withdrawAllToSplitter();
emit StrategyRemoved(strategy);
}
Expand Down Expand Up @@ -558,7 +557,7 @@ contract StrategySplitterV2 is ControllableV3, ReentrancyGuard, ISplitter {

/// @dev Register profit/loss data for the strategy.
/// Sender assume to be a registered strategy.
/// Suppose to be used in actions where we updated assets price and need to cover the price diff gap.
/// Suppose to be used in actions where we updated assets price and need to check the price diff gap.
function registerStrategyLoss(uint earned, uint lost) external override {
address strategy = msg.sender;
require(isValidStrategy[strategy], "SS: Invalid strategy");
Expand Down Expand Up @@ -651,9 +650,9 @@ contract StrategySplitterV2 is ControllableV3, ReentrancyGuard, ISplitter {
) internal returns (uint apr, uint avgApr) {
apr = 0;
avgApr = 0;
uint lostForCovering = lost > earned ? lost - earned : 0;
if (lostForCovering > 0) {
_checkLoss(lostForCovering, HARDWORK_LOSS_TOLERANCE, strategyTvl);
uint lostForCheck = lost > earned ? lost - earned : 0;
if (lostForCheck > 0) {
_checkLoss(lostForCheck, HARDWORK_LOSS_TOLERANCE, strategyTvl);
}

if (registerApr) {
Expand Down
16 changes: 2 additions & 14 deletions contracts/vault/VaultFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import "../interfaces/IERC20.sol";
import "../interfaces/ITetuVaultV2.sol";
import "../interfaces/ISplitter.sol";
import "../proxy/ProxyControlled.sol";
import "./VaultInsurance.sol";
import "../lib/InterfaceIds.sol";

/// @title Factory for vaults.
/// @author belbix
/// @author a17
contract VaultFactory is TetuERC165 {

// *************************************************************
Expand All @@ -31,8 +31,7 @@ contract VaultFactory is TetuERC165 {

/// @dev TetuVaultV2 contract address
address public vaultImpl;
/// @dev VaultInsurance contract address
address public vaultInsuranceImpl;

/// @dev StrategySplitterV2 contract address
address public splitterImpl;

Expand All @@ -56,23 +55,19 @@ contract VaultFactory is TetuERC165 {
address splitterLogic
);
event VaultImplChanged(address value);
event VaultInsuranceImplChanged(address value);
event SplitterImplChanged(address value);

constructor(
address _controller,
address _vaultImpl,
address _vaultInsuranceImpl,
address _splitterImpl
) {
_requireInterface(_controller, InterfaceIds.I_CONTROLLER);
_requireInterface(_vaultImpl, InterfaceIds.I_TETU_VAULT_V2);
_requireInterface(_vaultInsuranceImpl, InterfaceIds.I_VAULT_INSURANCE);
_requireInterface(_splitterImpl, InterfaceIds.I_SPLITTER);

controller = _controller;
vaultImpl = _vaultImpl;
vaultInsuranceImpl = _vaultInsuranceImpl;
splitterImpl = _splitterImpl;
}

Expand Down Expand Up @@ -107,13 +102,6 @@ contract VaultFactory is TetuERC165 {
emit VaultImplChanged(value);
}

/// @dev Set VaultInsurance contract address
function setVaultInsuranceImpl(address value) external onlyGov {
_requireInterface(value, InterfaceIds.I_VAULT_INSURANCE);
vaultInsuranceImpl = value;
emit VaultInsuranceImplChanged(value);
}

/// @dev Set StrategySplitterV2 contract address
function setSplitterImpl(address value) external onlyGov {
_requireInterface(value, InterfaceIds.I_SPLITTER);
Expand Down
44 changes: 0 additions & 44 deletions contracts/vault/VaultInsurance.sol

This file was deleted.

Loading

0 comments on commit e6eecb4

Please sign in to comment.