diff --git a/ape-config.yaml b/ape-config.yaml index 384b2ff..a37dc94 100644 --- a/ape-config.yaml +++ b/ape-config.yaml @@ -27,7 +27,9 @@ dependencies: github: yearn/tokenized-strategy ref: v3.0.1 contracts_folder: src - + exclude: + - test/**/* + - name: tokenized-strategy github: yearn/tokenized-strategy ref: v3.0.1 diff --git a/contracts/Mocks/MockTokenizedStrategy.sol b/contracts/Mocks/MockTokenizedStrategy.sol index 8709463..7564a9b 100644 --- a/contracts/Mocks/MockTokenizedStrategy.sol +++ b/contracts/Mocks/MockTokenizedStrategy.sol @@ -1,7 +1,85 @@ // SPDX-License-Identifier: AGPL-3.0 pragma solidity 0.8.18; -import {MockTokenizedStrategy} from "@yearn-vaults/test/mocks/ERC4626/MockTokenizedStrategy.sol"; +// SPDX-License-Identifier: GPL-3.0 +pragma solidity 0.8.18; + +import {TokenizedStrategy, ERC20} from "@tokenized-strategy/TokenizedStrategy.sol"; + +contract MockTokenizedStrategy is TokenizedStrategy { + uint256 public minDebt; + uint256 public maxDebt = type(uint256).max; + + // Private variables and functions used in this mock. + bytes32 public constant BASE_STRATEGY_STORAGE = + bytes32(uint256(keccak256("yearn.base.strategy.storage")) - 1); + + function strategyStorage() internal pure returns (StrategyData storage S) { + // Since STORAGE_SLOT is a constant, we have to put a variable + // on the stack to access it from an inline assembly block. + bytes32 slot = BASE_STRATEGY_STORAGE; + assembly { + S.slot := slot + } + } + + constructor( + address _asset, + string memory _name, + address _management, + address _keeper + ) { + // Cache storage pointer + StrategyData storage S = strategyStorage(); + + // Set the strategy's underlying asset + S.asset = ERC20(_asset); + // Set the Strategy Tokens name. + S.name = _name; + // Set decimals based off the `asset`. + S.decimals = ERC20(_asset).decimals(); + + // Set last report to this block. + S.lastReport = uint128(block.timestamp); + + // Set the default management address. Can't be 0. + require(_management != address(0), "ZERO ADDRESS"); + S.management = _management; + S.performanceFeeRecipient = _management; + // Set the keeper address + S.keeper = _keeper; + } + + function setMinDebt(uint256 _minDebt) external { + minDebt = _minDebt; + } + + function setMaxDebt(uint256 _maxDebt) external { + maxDebt = _maxDebt; + } + + function availableDepositLimit( + address + ) public view virtual returns (uint256) { + uint256 _totalAssets = strategyStorage().totalIdle; + uint256 _maxDebt = maxDebt; + return _maxDebt > _totalAssets ? _maxDebt - _totalAssets : 0; + } + + function availableWithdrawLimit( + address /*_owner*/ + ) public view virtual returns (uint256) { + return type(uint256).max; + } + + function deployFunds(uint256 _amount) external virtual {} + + function freeFunds(uint256 _amount) external virtual {} + + function harvestAndReport() external virtual returns (uint256) { + return strategyStorage().asset.balanceOf(address(this)); + } +} contract MockTokenized is MockTokenizedStrategy { uint256 public apr;