forked from GalloDaSballo/badger-vaults-mix-v1.5
-
Notifications
You must be signed in to change notification settings - Fork 9
/
MyStrategy.sol
117 lines (94 loc) · 4.68 KB
/
MyStrategy.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;
import {BaseStrategy} from "@badger-finance/BaseStrategy.sol";
contract MyStrategy is BaseStrategy {
// address public want; // Inherited from BaseStrategy
// address public lpComponent; // Token that represents ownership in a pool, not always used
// address public reward; // Token we farm
address constant BADGER = 0x3472A5A71965499acd81997a54BBA8D852C6E53d;
/// @dev Initialize the Strategy with security settings as well as tokens
/// @notice Proxies will set any non constant variable you declare as default value
/// @dev add any extra changeable variable at end of initializer as shown
function initialize(address _vault, address[1] memory _wantConfig) public initializer {
__BaseStrategy_init(_vault);
/// @dev Add config here
want = _wantConfig[0];
// If you need to set new values that are not constants, set them like so
// stakingContract = 0x79ba8b76F61Db3e7D994f7E384ba8f7870A043b7;
// If you need to do one-off approvals do them here like so
// IERC20Upgradeable(reward).safeApprove(
// address(DX_SWAP_ROUTER),
// type(uint256).max
// );
}
/// @dev Return the name of the strategy
function getName() external pure override returns (string memory) {
return "MyStrategy";
}
/// @dev Return a list of protected tokens
/// @notice It's very important all tokens that are meant to be in the strategy to be marked as protected
/// @notice this provides security guarantees to the depositors they can't be sweeped away
function getProtectedTokens() public view virtual override returns (address[] memory) {
address[] memory protectedTokens = new address[](2);
protectedTokens[0] = want;
protectedTokens[1] = BADGER;
return protectedTokens;
}
/// @dev Deposit `_amount` of want, investing it to earn yield
function _deposit(uint256 _amount) internal override {
// Add code here to invest `_amount` of want to earn yield
}
/// @dev Withdraw all funds, this is used for migrations, most of the time for emergency reasons
function _withdrawAll() internal override {
// Add code here to unlock all available funds
}
/// @dev Withdraw `_amount` of want, so that it can be sent to the vault / depositor
/// @notice just unlock the funds and return the amount you could unlock
function _withdrawSome(uint256 _amount) internal override returns (uint256) {
// Add code here to unlock / withdraw `_amount` of tokens to the withdrawer
// If there's a loss, make sure to have the withdrawer pay the loss to avoid exploits
// Socializing loss is always a bad idea
return _amount;
}
/// @dev Does this function require `tend` to be called?
function _isTendable() internal override pure returns (bool) {
return false; // Change to true if the strategy should be tended
}
function _harvest() internal override returns (TokenAmount[] memory harvested) {
// No-op as we don't do anything with funds
// use autoCompoundRatio here to convert rewards to want ...
// Nothing harvested, we have 2 tokens, return both 0s
harvested = new TokenAmount[](2);
harvested[0] = TokenAmount(want, 0);
harvested[1] = TokenAmount(BADGER, 0);
// keep this to get paid!
_reportToVault(0);
// Use this if your strategy doesn't sell the extra tokens
// This will take fees and send the token to the badgerTree
_processExtraToken(BADGER, 0);
return harvested;
}
// Example tend is a no-op which returns the values, could also just revert
function _tend() internal override returns (TokenAmount[] memory tended){
// Nothing tended
tended = new TokenAmount[](2);
tended[0] = TokenAmount(want, 0);
tended[1] = TokenAmount(BADGER, 0);
return tended;
}
/// @dev Return the balance (in want) that the strategy has invested somewhere
function balanceOfPool() public view override returns (uint256) {
// Change this to return the amount of want invested in another protocol
return 0;
}
/// @dev Return the balance of rewards that the strategy has accrued
/// @notice Used for offChain APY and Harvest Health monitoring
function balanceOfRewards() external view override returns (TokenAmount[] memory rewards) {
// Rewards are 0
rewards = new TokenAmount[](2);
rewards[0] = TokenAmount(want, 0);
rewards[1] = TokenAmount(BADGER, 0);
return rewards;
}
}