-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
45b5d6b
commit cc77711
Showing
11 changed files
with
120 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// 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(); | ||
|
||
// Default to an instant profit unlock period | ||
S.profitMaxUnlockTime = 0; | ||
// set to a 0% performance fee. | ||
S.performanceFee = 0; | ||
// 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 returns (uint256) { | ||
uint256 _totalAssets = strategyStorage().totalIdle; | ||
uint256 _maxDebt = maxDebt; | ||
return _maxDebt > _totalAssets ? _maxDebt - _totalAssets : 0; | ||
} | ||
|
||
function availableWithdrawLimit( | ||
address /*_owner*/ | ||
) public view returns (uint256) { | ||
return type(uint256).max; | ||
} | ||
|
||
function deployFunds(uint256 _amount) external {} | ||
|
||
function freeFunds(uint256 _amount) external {} | ||
|
||
function harvestAndReport() external returns (uint256) { | ||
return strategyStorage().asset.balanceOf(address(this)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters