@harvest-finance/harvest-strategy-arbitrum 0.0.1-security → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @harvest-finance/harvest-strategy-arbitrum might be problematic. Click here for more details.
- package/README.md +127 -5
- package/contracts/base/Controller.sol +358 -0
- package/contracts/base/Drip.sol +86 -0
- package/contracts/base/PotPool.sol +367 -0
- package/contracts/base/ProfitSharingReceiver.sol +38 -0
- package/contracts/base/Reader.sol +54 -0
- package/contracts/base/RewardForwarder.sol +109 -0
- package/contracts/base/VaultProxy.sol +34 -0
- package/contracts/base/VaultStorage.sol +205 -0
- package/contracts/base/VaultV1.sol +371 -0
- package/contracts/base/VaultV1GMX.sol +465 -0
- package/contracts/base/VaultV2.sol +111 -0
- package/contracts/base/VaultV2GMX.sol +111 -0
- package/contracts/base/factory/MegaFactory.sol +120 -0
- package/contracts/base/factory/interface/IPoolFactory.sol +6 -0
- package/contracts/base/factory/interface/IStrategyFactory.sol +6 -0
- package/contracts/base/factory/interface/IVaultFactory.sol +7 -0
- package/contracts/base/factory/pool/PotPoolFactory.sol +41 -0
- package/contracts/base/factory/strategy/UpgradableStrategyFactory.sol +19 -0
- package/contracts/base/factory/vault/RegularVaultFactory.sol +34 -0
- package/contracts/base/incentives/GlobalIncentivesExecutor.sol +85 -0
- package/contracts/base/incentives/GlobalIncentivesHelper.sol +174 -0
- package/contracts/base/incentives/NotifyHelperGeneric.sol +61 -0
- package/contracts/base/incentives/NotifyHelperStateful.sol +290 -0
- package/contracts/base/incentives/ViewerNotifyHelperStateful.sol +25 -0
- package/contracts/base/inheritance/Controllable.sol +25 -0
- package/contracts/base/inheritance/ControllableInit.sol +30 -0
- package/contracts/base/inheritance/Governable.sol +28 -0
- package/contracts/base/inheritance/GovernableInit.sol +50 -0
- package/contracts/base/inheritance/IUpgradeSource.sol +7 -0
- package/contracts/base/inheritance/OwnableWhitelist.sol +17 -0
- package/contracts/base/inheritance/Storage.sol +35 -0
- package/contracts/base/interface/IBalDex.sol +7 -0
- package/contracts/base/interface/IController.sol +132 -0
- package/contracts/base/interface/IDex.sol +9 -0
- package/contracts/base/interface/IERC4626.sol +261 -0
- package/contracts/base/interface/IGMXStrategy.sol +37 -0
- package/contracts/base/interface/IGlobalIncentivesHelper.sol +6 -0
- package/contracts/base/interface/IPotPool.sol +70 -0
- package/contracts/base/interface/IProfitSharingReceiver.sol +9 -0
- package/contracts/base/interface/IRewardForwarder.sol +57 -0
- package/contracts/base/interface/IStrategy.sol +37 -0
- package/contracts/base/interface/IUniversalLiquidator.sol +21 -0
- package/contracts/base/interface/IUniversalLiquidatorRegistry.sol +20 -0
- package/contracts/base/interface/IUpgradeSource.sol +9 -0
- package/contracts/base/interface/IVault.sol +58 -0
- package/contracts/base/interface/IVaultGMX.sol +71 -0
- package/contracts/base/interface/aura/IAuraBaseRewardPool.sol +25 -0
- package/contracts/base/interface/aura/IAuraBooster.sol +17 -0
- package/contracts/base/interface/aura/IAuraDepositor.sol +7 -0
- package/contracts/base/interface/balancer/Gauge.sol +22 -0
- package/contracts/base/interface/balancer/IBVault.sol +580 -0
- package/contracts/base/interface/balancer/IBalancerMinter.sol +114 -0
- package/contracts/base/interface/balancer/IGyroPool.sol +7 -0
- package/contracts/base/interface/balancer/linearPool/ILinearPool.sol +184 -0
- package/contracts/base/interface/balancer/linearPool/ILinearPoolFactory.sol +16 -0
- package/contracts/base/interface/balancer/linearPool/ILinearPoolRebalancer.sol +8 -0
- package/contracts/base/interface/balancer/linearPool/IPoolSwapStructs.sol +56 -0
- package/contracts/base/interface/compound/CTokenInterface.sol +29 -0
- package/contracts/base/interface/compound/IComptroller.sol +9 -0
- package/contracts/base/interface/dolomite/IDepositWithdraw.sol +13 -0
- package/contracts/base/interface/dolomite/IDolomiteMargin.sol +15 -0
- package/contracts/base/interface/dolomite/IRewardsDistributor.sol +11 -0
- package/contracts/base/interface/gamma/IClearing.sol +7 -0
- package/contracts/base/interface/gamma/IHypervisor.sol +9 -0
- package/contracts/base/interface/gamma/IUniProxy.sol +14 -0
- package/contracts/base/interface/gmx/EventUtils.sol +253 -0
- package/contracts/base/interface/gmx/ICallbackReceiver.sol +119 -0
- package/contracts/base/interface/gmx/IDataStore.sol +7 -0
- package/contracts/base/interface/gmx/IExchangeRouter.sol +38 -0
- package/contracts/base/interface/gmx/IGMXViewer.sol +7 -0
- package/contracts/base/interface/gmx/IHandler.sol +12 -0
- package/contracts/base/interface/gmx/IMarket.sol +7 -0
- package/contracts/base/interface/gmx/IOracle.sol +6 -0
- package/contracts/base/interface/gmx/IPriceFeed.sol +12 -0
- package/contracts/base/interface/gmx/IReader.sol +49 -0
- package/contracts/base/interface/gmx/IRoleStore.sol +6 -0
- package/contracts/base/interface/ipor/Errors.sol +20 -0
- package/contracts/base/interface/ipor/FuseStorageLib.sol +71 -0
- package/contracts/base/interface/ipor/FusesLib.sol +149 -0
- package/contracts/base/interface/ipor/IFuseCommon.sol +9 -0
- package/contracts/base/interface/ipor/IFuseInstantWithdraw.sol +14 -0
- package/contracts/base/interface/ipor/IMarketBalanceFuse.sol +10 -0
- package/contracts/base/interface/ipor/IPriceOracleMiddleware.sol +42 -0
- package/contracts/base/interface/ipor/IporMath.sol +110 -0
- package/contracts/base/interface/ipor/PlasmaVaultConfigLib.sol +106 -0
- package/contracts/base/interface/ipor/PlasmaVaultLib.sol +293 -0
- package/contracts/base/interface/ipor/PlasmaVaultStorageLib.sol +352 -0
- package/contracts/base/interface/merkl/IDistributor.sol +6 -0
- package/contracts/base/interface/notional/INProxy.sol +44 -0
- package/contracts/base/interface/notional/IPrimeToken.sol +6 -0
- package/contracts/base/interface/venus/IRewardsDistributor.sol +6 -0
- package/contracts/base/interface/weth/IWETH.sol +39 -0
- package/contracts/base/ipor/Erc4626BalanceFuse.sol +54 -0
- package/contracts/base/ipor/Erc4626SupplyFuse.sol +134 -0
- package/contracts/base/noop/NoopStrategyUpgradeable.sol +90 -0
- package/contracts/base/upgradability/BaseUpgradeabilityProxy.sol +60 -0
- package/contracts/base/upgradability/BaseUpgradeableStrategy.sol +144 -0
- package/contracts/base/upgradability/BaseUpgradeableStrategyStorage.sol +284 -0
- package/contracts/base/upgradability/IUpgradable.sol +7 -0
- package/contracts/base/upgradability/ReentrancyGuardUpgradeable.sol +51 -0
- package/contracts/base/upgradability/StrategyProxy.sol +34 -0
- package/contracts/strategies/aura/AuraStrategy.sol +403 -0
- package/contracts/strategies/aura/AuraStrategyMainnet_MORE_GYD.sol +32 -0
- package/contracts/strategies/aura/AuraStrategyMainnet_sUSDe_GYD.sol +31 -0
- package/contracts/strategies/aura/AuraStrategyMainnet_waFRAX_sFRAX.sol +31 -0
- package/contracts/strategies/aura/AuraStrategyMainnet_waGHO_GYD.sol +31 -0
- package/contracts/strategies/aura/AuraStrategyMainnet_waUSDC_GHO.sol +32 -0
- package/contracts/strategies/aura/AuraStrategyMainnet_waUSDC_GYD.sol +31 -0
- package/contracts/strategies/aura/AuraStrategyMainnet_waUSDT_GYD.sol +31 -0
- package/contracts/strategies/aura/AuraStrategyMainnet_wstETH_GYD.sol +31 -0
- package/contracts/strategies/camelot/CamelotV3Strategy.sol +304 -0
- package/contracts/strategies/camelot/CamelotV3StrategyMainnet_ARB_USDC.sol +28 -0
- package/contracts/strategies/camelot/CamelotV3StrategyMainnet_ETH_USDC.sol +28 -0
- package/contracts/strategies/camelot/CamelotV3StrategyMainnet_ETH_USDT.sol +28 -0
- package/contracts/strategies/camelot/CamelotV3StrategyMainnet_GMX_ETH.sol +28 -0
- package/contracts/strategies/camelot/CamelotV3StrategyMainnet_GRAIL_ETH.sol +28 -0
- package/contracts/strategies/camelot/CamelotV3StrategyMainnet_USDC_USDT.sol +28 -0
- package/contracts/strategies/camelot/CamelotV3StrategyMainnet_WBTC_ETH.sol +28 -0
- package/contracts/strategies/dolomite/DolomiteLendStrategy.sol +273 -0
- package/contracts/strategies/dolomite/DolomiteLendStrategyMainnet_DAI.sol +26 -0
- package/contracts/strategies/dolomite/DolomiteLendStrategyMainnet_GMX.sol +26 -0
- package/contracts/strategies/dolomite/DolomiteLendStrategyMainnet_USDC.sol +26 -0
- package/contracts/strategies/dolomite/DolomiteLendStrategyMainnet_USDCe.sol +26 -0
- package/contracts/strategies/dolomite/DolomiteLendStrategyMainnet_USDT.sol +26 -0
- package/contracts/strategies/dolomite/DolomiteLendStrategyMainnet_WBTC.sol +26 -0
- package/contracts/strategies/dolomite/DolomiteLendStrategyMainnet_WETH.sol +26 -0
- package/contracts/strategies/fluid/FluidLendStrategy.sol +241 -0
- package/contracts/strategies/fluid/FluidLendStrategyMainnet_ETH.sol +25 -0
- package/contracts/strategies/fluid/FluidLendStrategyMainnet_USDC.sol +25 -0
- package/contracts/strategies/fluid/FluidLendStrategyMainnet_USDT.sol +25 -0
- package/contracts/strategies/gmx/GMXStrategy.sol +472 -0
- package/contracts/strategies/gmx/GMXStrategyMainnet_WBTC.sol +25 -0
- package/contracts/strategies/gmx/GMXViewer.sol +110 -0
- package/contracts/strategies/notional/NotionalStrategy.sol +223 -0
- package/contracts/strategies/notional/NotionalStrategyMainnet_nETH.sol +27 -0
- package/contracts/strategies/notional/NotionalStrategyMainnet_nUSDC.sol +27 -0
- package/contracts/strategies/notional/NotionalStrategyMainnet_nUSDT.sol +27 -0
- package/contracts/strategies/notional/NotionalStrategyMainnet_nwstETH.sol +27 -0
- package/contracts/strategies/venus/VenusFoldStrategy.sol +591 -0
- package/contracts/strategies/venus/VenusFoldStrategyMainnet_ARB.sol +32 -0
- package/contracts/strategies/venus/VenusFoldStrategyMainnet_ETH_core.sol +32 -0
- package/contracts/strategies/venus/VenusFoldStrategyMainnet_ETH_lsd.sol +32 -0
- package/contracts/strategies/venus/VenusFoldStrategyMainnet_USDC.sol +32 -0
- package/contracts/strategies/venus/VenusFoldStrategyMainnet_USDT.sol +32 -0
- package/contracts/strategies/venus/VenusFoldStrategyMainnet_WBTC.sol +32 -0
- package/hardhat.config.js +60 -0
- package/index.js +42 -0
- package/package.json +39 -6
- package/scripts/01-deploy-vault-regular-with-upgradable-strategy.js +41 -0
- package/scripts/02-deploy-vault-regular.js +35 -0
- package/scripts/03-deploy-upgradable-strategy.js +40 -0
- package/scripts/04-deploy-new-implementation.js +24 -0
- package/scripts/05-deploy-GMXViewer.js +17 -0
- package/scripts/06-deploy-GMXVault.js +49 -0
- package/scripts/07-deploy-ipor-fuses.js +29 -0
- package/scripts/08-deploy-drip.js +20 -0
- package/scripts/README.md +55 -0
- package/scripts/utils.js +22 -0
- package/test/aura/more-gyd.js +140 -0
- package/test/aura/susde-gyd.js +140 -0
- package/test/aura/wafrax-sfrax.js +140 -0
- package/test/aura/wagho-gyd.js +140 -0
- package/test/aura/wausdc-gho.js +141 -0
- package/test/aura/wausdc-gyd.js +140 -0
- package/test/aura/wausdt-gyd.js +140 -0
- package/test/aura/wsteth-gyd.js +138 -0
- package/test/camelot/arb-usdc.js +125 -0
- package/test/camelot/eth-usdc.js +125 -0
- package/test/camelot/eth-usdt.js +125 -0
- package/test/camelot/gmx-eth.js +125 -0
- package/test/camelot/grail-eth.js +125 -0
- package/test/camelot/usdc-usdt.js +125 -0
- package/test/camelot/wbtc-eth.js +125 -0
- package/test/dolomite/dai.js +127 -0
- package/test/dolomite/gmx.js +134 -0
- package/test/dolomite/usdc.js +127 -0
- package/test/dolomite/usdce.js +127 -0
- package/test/dolomite/usdt.js +127 -0
- package/test/dolomite/wbtc.js +127 -0
- package/test/dolomite/weth.js +127 -0
- package/test/fluid/eth.js +127 -0
- package/test/fluid/usdc.js +134 -0
- package/test/fluid/usdt.js +134 -0
- package/test/gmx/wbtc.js +184 -0
- package/test/notional/neth.js +133 -0
- package/test/notional/nusdc.js +133 -0
- package/test/notional/nusdt.js +133 -0
- package/test/notional/nwsteth.js +133 -0
- package/test/test-config.js +28 -0
- package/test/utilities/Utils.js +96 -0
- package/test/utilities/hh-utils.js +248 -0
- package/test/utilities/make-vault.js +16 -0
- package/test/venus/arb.js +135 -0
- package/test/venus/eth-core.js +133 -0
- package/test/venus/eth-lsd.js +133 -0
- package/test/venus/usdc.js +133 -0
- package/test/venus/usdt.js +133 -0
- package/test/venus/wbtc.js +133 -0
@@ -0,0 +1,284 @@
|
|
1
|
+
//SPDX-License-Identifier: Unlicense
|
2
|
+
pragma solidity 0.8.26;
|
3
|
+
|
4
|
+
import "../interface/IController.sol";
|
5
|
+
import "../inheritance/ControllableInit.sol";
|
6
|
+
|
7
|
+
contract BaseUpgradeableStrategyStorage is ControllableInit {
|
8
|
+
|
9
|
+
event ProfitsNotCollected(
|
10
|
+
address indexed rewardToken,
|
11
|
+
bool sell,
|
12
|
+
bool floor
|
13
|
+
);
|
14
|
+
event ProfitLogInReward(
|
15
|
+
address indexed rewardToken,
|
16
|
+
uint256 profitAmount,
|
17
|
+
uint256 feeAmount,
|
18
|
+
uint256 timestamp
|
19
|
+
);
|
20
|
+
event PlatformFeeLogInReward(
|
21
|
+
address indexed treasury,
|
22
|
+
address indexed rewardToken,
|
23
|
+
uint256 profitAmount,
|
24
|
+
uint256 feeAmount,
|
25
|
+
uint256 timestamp
|
26
|
+
);
|
27
|
+
event StrategistFeeLogInReward(
|
28
|
+
address indexed strategist,
|
29
|
+
address indexed rewardToken,
|
30
|
+
uint256 profitAmount,
|
31
|
+
uint256 feeAmount,
|
32
|
+
uint256 timestamp
|
33
|
+
);
|
34
|
+
|
35
|
+
bytes32 internal constant _UNDERLYING_SLOT = 0xa1709211eeccf8f4ad5b6700d52a1a9525b5f5ae1e9e5f9e5a0c2fc23c86e530;
|
36
|
+
bytes32 internal constant _VAULT_SLOT = 0xefd7c7d9ef1040fc87e7ad11fe15f86e1d11e1df03c6d7c87f7e1f4041f08d41;
|
37
|
+
|
38
|
+
bytes32 internal constant _REWARD_TOKEN_SLOT = 0xdae0aafd977983cb1e78d8f638900ff361dc3c48c43118ca1dd77d1af3f47bbf;
|
39
|
+
// bytes32 internal constant _REWARD_TOKENS_SLOT = 0x45418d9b5c2787ae64acbffccad43f2b487c1a16e24385aa9d2b059f9d1d163c;
|
40
|
+
bytes32 internal constant _REWARD_POOL_SLOT = 0x3d9bb16e77837e25cada0cf894835418b38e8e18fbec6cfd192eb344bebfa6b8;
|
41
|
+
// bytes32 internal constant _SELL_FLOOR_SLOT = 0xc403216a7704d160f6a3b5c3b149a1226a6080f0a5dd27b27d9ba9c022fa0afc;
|
42
|
+
bytes32 internal constant _SELL_SLOT = 0x656de32df98753b07482576beb0d00a6b949ebf84c066c765f54f26725221bb6;
|
43
|
+
bytes32 internal constant _PAUSED_INVESTING_SLOT = 0xa07a20a2d463a602c2b891eb35f244624d9068572811f63d0e094072fb54591a;
|
44
|
+
|
45
|
+
bytes32 internal constant _PROFIT_SHARING_NUMERATOR_SLOT = 0xe3ee74fb7893020b457d8071ed1ef76ace2bf4903abd7b24d3ce312e9c72c029;
|
46
|
+
bytes32 internal constant _PROFIT_SHARING_DENOMINATOR_SLOT = 0x0286fd414602b432a8c80a0125e9a25de9bba96da9d5068c832ff73f09208a3b;
|
47
|
+
|
48
|
+
bytes32 internal constant _NEXT_IMPLEMENTATION_SLOT = 0x29f7fcd4fe2517c1963807a1ec27b0e45e67c60a874d5eeac7a0b1ab1bb84447;
|
49
|
+
bytes32 internal constant _NEXT_IMPLEMENTATION_TIMESTAMP_SLOT = 0x414c5263b05428f1be1bfa98e25407cc78dd031d0d3cd2a2e3d63b488804f22e;
|
50
|
+
bytes32 internal constant _NEXT_IMPLEMENTATION_DELAY_SLOT = 0x82b330ca72bcd6db11a26f10ce47ebcfe574a9c646bccbc6f1cd4478eae16b31;
|
51
|
+
|
52
|
+
bytes32 internal constant _STRATEGIST_SLOT = 0x6a7b588c950d46e2de3db2f157e5e0e4f29054c8d60f17bf0c30352e223a458d;
|
53
|
+
|
54
|
+
constructor() {
|
55
|
+
assert(_UNDERLYING_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.underlying")) - 1));
|
56
|
+
assert(_VAULT_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.vault")) - 1));
|
57
|
+
assert(_REWARD_TOKEN_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.rewardToken")) - 1));
|
58
|
+
// assert(_REWARD_TOKENS_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.rewardTokens")) - 1));
|
59
|
+
assert(_REWARD_POOL_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.rewardPool")) - 1));
|
60
|
+
// assert(_SELL_FLOOR_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.sellFloor")) - 1));
|
61
|
+
assert(_SELL_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.sell")) - 1));
|
62
|
+
assert(_PAUSED_INVESTING_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.pausedInvesting")) - 1));
|
63
|
+
|
64
|
+
assert(_PROFIT_SHARING_NUMERATOR_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.profitSharingNumerator")) - 1));
|
65
|
+
assert(_PROFIT_SHARING_DENOMINATOR_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.profitSharingDenominator")) - 1));
|
66
|
+
|
67
|
+
assert(_NEXT_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.nextImplementation")) - 1));
|
68
|
+
assert(_NEXT_IMPLEMENTATION_TIMESTAMP_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.nextImplementationTimestamp")) - 1));
|
69
|
+
assert(_NEXT_IMPLEMENTATION_DELAY_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.nextImplementationDelay")) - 1));
|
70
|
+
|
71
|
+
assert(_STRATEGIST_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.strategist")) - 1));
|
72
|
+
}
|
73
|
+
|
74
|
+
function _setUnderlying(address _address) internal {
|
75
|
+
setAddress(_UNDERLYING_SLOT, _address);
|
76
|
+
}
|
77
|
+
|
78
|
+
function underlying() public virtual view returns (address) {
|
79
|
+
return getAddress(_UNDERLYING_SLOT);
|
80
|
+
}
|
81
|
+
|
82
|
+
function _setRewardPool(address _address) internal {
|
83
|
+
setAddress(_REWARD_POOL_SLOT, _address);
|
84
|
+
}
|
85
|
+
|
86
|
+
function rewardPool() public view returns (address) {
|
87
|
+
return getAddress(_REWARD_POOL_SLOT);
|
88
|
+
}
|
89
|
+
|
90
|
+
function _setRewardToken(address _address) internal {
|
91
|
+
setAddress(_REWARD_TOKEN_SLOT, _address);
|
92
|
+
}
|
93
|
+
|
94
|
+
function rewardToken() public view returns (address) {
|
95
|
+
return getAddress(_REWARD_TOKEN_SLOT);
|
96
|
+
}
|
97
|
+
|
98
|
+
// function _setRewardTokens(address[] memory _rewardTokens) internal {
|
99
|
+
// setAddressArray(_REWARD_TOKENS_SLOT, _rewardTokens);
|
100
|
+
// }
|
101
|
+
|
102
|
+
// function isRewardToken(address _token) public view returns (bool) {
|
103
|
+
// return _isAddressInList(_token, rewardTokens());
|
104
|
+
// }
|
105
|
+
|
106
|
+
// function rewardTokens() public view returns (address[] memory) {
|
107
|
+
// return getAddressArray(_REWARD_TOKENS_SLOT);
|
108
|
+
// }
|
109
|
+
|
110
|
+
function _isAddressInList(address _searchValue, address[] memory _list) internal pure returns (bool) {
|
111
|
+
for (uint i = 0; i < _list.length; i++) {
|
112
|
+
if (_list[i] == _searchValue) {
|
113
|
+
return true;
|
114
|
+
}
|
115
|
+
}
|
116
|
+
return false;
|
117
|
+
}
|
118
|
+
|
119
|
+
function _setStrategist(address _strategist) internal {
|
120
|
+
setAddress(_STRATEGIST_SLOT, _strategist);
|
121
|
+
}
|
122
|
+
|
123
|
+
function strategist() public view returns (address) {
|
124
|
+
return getAddress(_STRATEGIST_SLOT);
|
125
|
+
}
|
126
|
+
|
127
|
+
function _setVault(address _address) internal {
|
128
|
+
setAddress(_VAULT_SLOT, _address);
|
129
|
+
}
|
130
|
+
|
131
|
+
function vault() public virtual view returns (address) {
|
132
|
+
return getAddress(_VAULT_SLOT);
|
133
|
+
}
|
134
|
+
|
135
|
+
// a flag for disabling selling for simplified emergency exit
|
136
|
+
function _setSell(bool _value) internal {
|
137
|
+
setBoolean(_SELL_SLOT, _value);
|
138
|
+
}
|
139
|
+
|
140
|
+
function sell() public view returns (bool) {
|
141
|
+
return getBoolean(_SELL_SLOT);
|
142
|
+
}
|
143
|
+
|
144
|
+
function _setPausedInvesting(bool _value) internal {
|
145
|
+
setBoolean(_PAUSED_INVESTING_SLOT, _value);
|
146
|
+
}
|
147
|
+
|
148
|
+
function pausedInvesting() public view returns (bool) {
|
149
|
+
return getBoolean(_PAUSED_INVESTING_SLOT);
|
150
|
+
}
|
151
|
+
|
152
|
+
// function _setSellFloor(uint256 _value) internal {
|
153
|
+
// setUint256(_SELL_FLOOR_SLOT, _value);
|
154
|
+
// }
|
155
|
+
|
156
|
+
// function sellFloor() public view returns (uint256) {
|
157
|
+
// return getUint256(_SELL_FLOOR_SLOT);
|
158
|
+
// }
|
159
|
+
|
160
|
+
function profitSharingNumerator() public view returns (uint256) {
|
161
|
+
return IController(controller()).profitSharingNumerator();
|
162
|
+
}
|
163
|
+
|
164
|
+
function platformFeeNumerator() public view returns (uint256) {
|
165
|
+
return IController(controller()).platformFeeNumerator();
|
166
|
+
}
|
167
|
+
|
168
|
+
function strategistFeeNumerator() public view returns (uint256) {
|
169
|
+
return IController(controller()).strategistFeeNumerator();
|
170
|
+
}
|
171
|
+
|
172
|
+
function feeDenominator() public view returns (uint256) {
|
173
|
+
return IController(controller()).feeDenominator();
|
174
|
+
}
|
175
|
+
|
176
|
+
function universalLiquidator() public view returns (address) {
|
177
|
+
return IController(controller()).universalLiquidator();
|
178
|
+
}
|
179
|
+
|
180
|
+
// upgradeability
|
181
|
+
|
182
|
+
function _setNextImplementation(address _address) internal {
|
183
|
+
setAddress(_NEXT_IMPLEMENTATION_SLOT, _address);
|
184
|
+
}
|
185
|
+
|
186
|
+
function nextImplementation() public view returns (address) {
|
187
|
+
return getAddress(_NEXT_IMPLEMENTATION_SLOT);
|
188
|
+
}
|
189
|
+
|
190
|
+
function _setNextImplementationTimestamp(uint256 _value) internal {
|
191
|
+
setUint256(_NEXT_IMPLEMENTATION_TIMESTAMP_SLOT, _value);
|
192
|
+
}
|
193
|
+
|
194
|
+
function nextImplementationTimestamp() public view returns (uint256) {
|
195
|
+
return getUint256(_NEXT_IMPLEMENTATION_TIMESTAMP_SLOT);
|
196
|
+
}
|
197
|
+
|
198
|
+
function nextImplementationDelay() public view returns (uint256) {
|
199
|
+
return IController(controller()).nextImplementationDelay();
|
200
|
+
}
|
201
|
+
|
202
|
+
function setBoolean(bytes32 slot, bool _value) internal {
|
203
|
+
setUint256(slot, _value ? 1 : 0);
|
204
|
+
}
|
205
|
+
|
206
|
+
function getBoolean(bytes32 slot) internal view returns (bool) {
|
207
|
+
return (getUint256(slot) == 1);
|
208
|
+
}
|
209
|
+
|
210
|
+
function setAddress(bytes32 slot, address _address) internal {
|
211
|
+
// solhint-disable-next-line no-inline-assembly
|
212
|
+
assembly {
|
213
|
+
sstore(slot, _address)
|
214
|
+
}
|
215
|
+
}
|
216
|
+
|
217
|
+
function setUint256(bytes32 slot, uint256 _value) internal {
|
218
|
+
// solhint-disable-next-line no-inline-assembly
|
219
|
+
assembly {
|
220
|
+
sstore(slot, _value)
|
221
|
+
}
|
222
|
+
}
|
223
|
+
|
224
|
+
function getAddress(bytes32 slot) internal view returns (address str) {
|
225
|
+
// solhint-disable-next-line no-inline-assembly
|
226
|
+
assembly {
|
227
|
+
str := sload(slot)
|
228
|
+
}
|
229
|
+
}
|
230
|
+
|
231
|
+
function getUint256(bytes32 slot) internal view returns (uint256 str) {
|
232
|
+
// solhint-disable-next-line no-inline-assembly
|
233
|
+
assembly {
|
234
|
+
str := sload(slot)
|
235
|
+
}
|
236
|
+
}
|
237
|
+
|
238
|
+
function setUint256Array(bytes32 slot, uint256[] memory _values) internal {
|
239
|
+
// solhint-disable-next-line no-inline-assembly
|
240
|
+
setUint256(slot, _values.length);
|
241
|
+
for (uint i = 0; i < _values.length; i++) {
|
242
|
+
setUint256(bytes32(uint(slot) + 1 + i), _values[i]);
|
243
|
+
}
|
244
|
+
}
|
245
|
+
|
246
|
+
function setAddressArray(bytes32 slot, address[] memory _values) internal {
|
247
|
+
// solhint-disable-next-line no-inline-assembly
|
248
|
+
setUint256(slot, _values.length);
|
249
|
+
for (uint i = 0; i < _values.length; i++) {
|
250
|
+
setAddress(bytes32(uint(slot) + 1 + i), _values[i]);
|
251
|
+
}
|
252
|
+
}
|
253
|
+
|
254
|
+
|
255
|
+
function getUint256Array(bytes32 slot) internal view returns (uint[] memory values) {
|
256
|
+
// solhint-disable-next-line no-inline-assembly
|
257
|
+
values = new uint[](getUint256(slot));
|
258
|
+
for (uint i = 0; i < values.length; i++) {
|
259
|
+
values[i] = getUint256(bytes32(uint(slot) + 1 + i));
|
260
|
+
}
|
261
|
+
}
|
262
|
+
|
263
|
+
function getAddressArray(bytes32 slot) internal view returns (address[] memory values) {
|
264
|
+
// solhint-disable-next-line no-inline-assembly
|
265
|
+
values = new address[](getUint256(slot));
|
266
|
+
for (uint i = 0; i < values.length; i++) {
|
267
|
+
values[i] = getAddress(bytes32(uint(slot) + 1 + i));
|
268
|
+
}
|
269
|
+
}
|
270
|
+
|
271
|
+
function setBytes32(bytes32 slot, bytes32 _value) internal {
|
272
|
+
// solhint-disable-next-line no-inline-assembly
|
273
|
+
assembly {
|
274
|
+
sstore(slot, _value)
|
275
|
+
}
|
276
|
+
}
|
277
|
+
|
278
|
+
function getBytes32(bytes32 slot) internal view returns (bytes32 str) {
|
279
|
+
// solhint-disable-next-line no-inline-assembly
|
280
|
+
assembly {
|
281
|
+
str := sload(slot)
|
282
|
+
}
|
283
|
+
}
|
284
|
+
}
|
@@ -0,0 +1,51 @@
|
|
1
|
+
//SPDX-License-Identifier: Unlicense
|
2
|
+
pragma solidity 0.8.26;
|
3
|
+
|
4
|
+
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Same old `ReentrancyGuard`, but can be used by upgradable contracts
|
8
|
+
*/
|
9
|
+
contract ReentrancyGuardUpgradeable is Initializable {
|
10
|
+
|
11
|
+
bytes32 internal constant _NOT_ENTERED_SLOT = 0x62ae7bf2df4e95c187ea09c8c47c3fc3d9abc36298f5b5b6c5e2e7b4b291fe25;
|
12
|
+
|
13
|
+
modifier nonReentrant() {
|
14
|
+
// On the first call to nonReentrant, _notEntered will be true
|
15
|
+
require(_getNotEntered(_NOT_ENTERED_SLOT), "ReentrancyGuard: reentrant call");
|
16
|
+
|
17
|
+
// Any calls to nonReentrant after this point will fail
|
18
|
+
_setNotEntered(_NOT_ENTERED_SLOT, false);
|
19
|
+
|
20
|
+
_;
|
21
|
+
|
22
|
+
// By storing the original value once again, a refund is triggered (see
|
23
|
+
// https://eips.ethereum.org/EIPS/eip-2200)
|
24
|
+
_setNotEntered(_NOT_ENTERED_SLOT, true);
|
25
|
+
}
|
26
|
+
|
27
|
+
constructor() {
|
28
|
+
assert(_NOT_ENTERED_SLOT == bytes32(uint256(keccak256("eip1967.reentrancyGuard.notEntered")) - 1));
|
29
|
+
}
|
30
|
+
|
31
|
+
function initialize() public initializer {
|
32
|
+
_setNotEntered(_NOT_ENTERED_SLOT, true);
|
33
|
+
}
|
34
|
+
|
35
|
+
function _getNotEntered(bytes32 slot) private view returns (bool) {
|
36
|
+
uint str;
|
37
|
+
// solhint-disable-next-line no-inline-assembly
|
38
|
+
assembly {
|
39
|
+
str := sload(slot)
|
40
|
+
}
|
41
|
+
return str == 1;
|
42
|
+
}
|
43
|
+
|
44
|
+
function _setNotEntered(bytes32 slot, bool _value) private {
|
45
|
+
// solhint-disable-next-line no-inline-assembly
|
46
|
+
assembly {
|
47
|
+
sstore(slot, _value)
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
//SPDX-License-Identifier: Unlicense
|
2
|
+
pragma solidity 0.8.26;
|
3
|
+
|
4
|
+
import "../inheritance/IUpgradeSource.sol";
|
5
|
+
import "./BaseUpgradeabilityProxy.sol";
|
6
|
+
|
7
|
+
contract StrategyProxy is BaseUpgradeabilityProxy {
|
8
|
+
|
9
|
+
constructor(address _implementation) {
|
10
|
+
_setImplementation(_implementation);
|
11
|
+
}
|
12
|
+
|
13
|
+
/**
|
14
|
+
* The main logic. If the timer has elapsed and there is a schedule upgrade,
|
15
|
+
* the governance can upgrade the strategy
|
16
|
+
*/
|
17
|
+
function upgrade() external {
|
18
|
+
(bool should, address newImplementation) = IUpgradeSource(address(this)).shouldUpgrade();
|
19
|
+
require(should, "Upgrade not scheduled");
|
20
|
+
_upgradeTo(newImplementation);
|
21
|
+
|
22
|
+
// the finalization needs to be executed on itself to update the storage of this proxy
|
23
|
+
// it also needs to be invoked by the governance, not by address(this), so delegatecall is needed
|
24
|
+
(bool success,) = address(this).delegatecall(
|
25
|
+
abi.encodeWithSignature("finalizeUpgrade()")
|
26
|
+
);
|
27
|
+
|
28
|
+
require(success, "Issue when finalizing the upgrade");
|
29
|
+
}
|
30
|
+
|
31
|
+
function implementation() external view returns (address) {
|
32
|
+
return _implementation();
|
33
|
+
}
|
34
|
+
}
|