@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.

Files changed (199) hide show
  1. package/README.md +127 -5
  2. package/contracts/base/Controller.sol +358 -0
  3. package/contracts/base/Drip.sol +86 -0
  4. package/contracts/base/PotPool.sol +367 -0
  5. package/contracts/base/ProfitSharingReceiver.sol +38 -0
  6. package/contracts/base/Reader.sol +54 -0
  7. package/contracts/base/RewardForwarder.sol +109 -0
  8. package/contracts/base/VaultProxy.sol +34 -0
  9. package/contracts/base/VaultStorage.sol +205 -0
  10. package/contracts/base/VaultV1.sol +371 -0
  11. package/contracts/base/VaultV1GMX.sol +465 -0
  12. package/contracts/base/VaultV2.sol +111 -0
  13. package/contracts/base/VaultV2GMX.sol +111 -0
  14. package/contracts/base/factory/MegaFactory.sol +120 -0
  15. package/contracts/base/factory/interface/IPoolFactory.sol +6 -0
  16. package/contracts/base/factory/interface/IStrategyFactory.sol +6 -0
  17. package/contracts/base/factory/interface/IVaultFactory.sol +7 -0
  18. package/contracts/base/factory/pool/PotPoolFactory.sol +41 -0
  19. package/contracts/base/factory/strategy/UpgradableStrategyFactory.sol +19 -0
  20. package/contracts/base/factory/vault/RegularVaultFactory.sol +34 -0
  21. package/contracts/base/incentives/GlobalIncentivesExecutor.sol +85 -0
  22. package/contracts/base/incentives/GlobalIncentivesHelper.sol +174 -0
  23. package/contracts/base/incentives/NotifyHelperGeneric.sol +61 -0
  24. package/contracts/base/incentives/NotifyHelperStateful.sol +290 -0
  25. package/contracts/base/incentives/ViewerNotifyHelperStateful.sol +25 -0
  26. package/contracts/base/inheritance/Controllable.sol +25 -0
  27. package/contracts/base/inheritance/ControllableInit.sol +30 -0
  28. package/contracts/base/inheritance/Governable.sol +28 -0
  29. package/contracts/base/inheritance/GovernableInit.sol +50 -0
  30. package/contracts/base/inheritance/IUpgradeSource.sol +7 -0
  31. package/contracts/base/inheritance/OwnableWhitelist.sol +17 -0
  32. package/contracts/base/inheritance/Storage.sol +35 -0
  33. package/contracts/base/interface/IBalDex.sol +7 -0
  34. package/contracts/base/interface/IController.sol +132 -0
  35. package/contracts/base/interface/IDex.sol +9 -0
  36. package/contracts/base/interface/IERC4626.sol +261 -0
  37. package/contracts/base/interface/IGMXStrategy.sol +37 -0
  38. package/contracts/base/interface/IGlobalIncentivesHelper.sol +6 -0
  39. package/contracts/base/interface/IPotPool.sol +70 -0
  40. package/contracts/base/interface/IProfitSharingReceiver.sol +9 -0
  41. package/contracts/base/interface/IRewardForwarder.sol +57 -0
  42. package/contracts/base/interface/IStrategy.sol +37 -0
  43. package/contracts/base/interface/IUniversalLiquidator.sol +21 -0
  44. package/contracts/base/interface/IUniversalLiquidatorRegistry.sol +20 -0
  45. package/contracts/base/interface/IUpgradeSource.sol +9 -0
  46. package/contracts/base/interface/IVault.sol +58 -0
  47. package/contracts/base/interface/IVaultGMX.sol +71 -0
  48. package/contracts/base/interface/aura/IAuraBaseRewardPool.sol +25 -0
  49. package/contracts/base/interface/aura/IAuraBooster.sol +17 -0
  50. package/contracts/base/interface/aura/IAuraDepositor.sol +7 -0
  51. package/contracts/base/interface/balancer/Gauge.sol +22 -0
  52. package/contracts/base/interface/balancer/IBVault.sol +580 -0
  53. package/contracts/base/interface/balancer/IBalancerMinter.sol +114 -0
  54. package/contracts/base/interface/balancer/IGyroPool.sol +7 -0
  55. package/contracts/base/interface/balancer/linearPool/ILinearPool.sol +184 -0
  56. package/contracts/base/interface/balancer/linearPool/ILinearPoolFactory.sol +16 -0
  57. package/contracts/base/interface/balancer/linearPool/ILinearPoolRebalancer.sol +8 -0
  58. package/contracts/base/interface/balancer/linearPool/IPoolSwapStructs.sol +56 -0
  59. package/contracts/base/interface/compound/CTokenInterface.sol +29 -0
  60. package/contracts/base/interface/compound/IComptroller.sol +9 -0
  61. package/contracts/base/interface/dolomite/IDepositWithdraw.sol +13 -0
  62. package/contracts/base/interface/dolomite/IDolomiteMargin.sol +15 -0
  63. package/contracts/base/interface/dolomite/IRewardsDistributor.sol +11 -0
  64. package/contracts/base/interface/gamma/IClearing.sol +7 -0
  65. package/contracts/base/interface/gamma/IHypervisor.sol +9 -0
  66. package/contracts/base/interface/gamma/IUniProxy.sol +14 -0
  67. package/contracts/base/interface/gmx/EventUtils.sol +253 -0
  68. package/contracts/base/interface/gmx/ICallbackReceiver.sol +119 -0
  69. package/contracts/base/interface/gmx/IDataStore.sol +7 -0
  70. package/contracts/base/interface/gmx/IExchangeRouter.sol +38 -0
  71. package/contracts/base/interface/gmx/IGMXViewer.sol +7 -0
  72. package/contracts/base/interface/gmx/IHandler.sol +12 -0
  73. package/contracts/base/interface/gmx/IMarket.sol +7 -0
  74. package/contracts/base/interface/gmx/IOracle.sol +6 -0
  75. package/contracts/base/interface/gmx/IPriceFeed.sol +12 -0
  76. package/contracts/base/interface/gmx/IReader.sol +49 -0
  77. package/contracts/base/interface/gmx/IRoleStore.sol +6 -0
  78. package/contracts/base/interface/ipor/Errors.sol +20 -0
  79. package/contracts/base/interface/ipor/FuseStorageLib.sol +71 -0
  80. package/contracts/base/interface/ipor/FusesLib.sol +149 -0
  81. package/contracts/base/interface/ipor/IFuseCommon.sol +9 -0
  82. package/contracts/base/interface/ipor/IFuseInstantWithdraw.sol +14 -0
  83. package/contracts/base/interface/ipor/IMarketBalanceFuse.sol +10 -0
  84. package/contracts/base/interface/ipor/IPriceOracleMiddleware.sol +42 -0
  85. package/contracts/base/interface/ipor/IporMath.sol +110 -0
  86. package/contracts/base/interface/ipor/PlasmaVaultConfigLib.sol +106 -0
  87. package/contracts/base/interface/ipor/PlasmaVaultLib.sol +293 -0
  88. package/contracts/base/interface/ipor/PlasmaVaultStorageLib.sol +352 -0
  89. package/contracts/base/interface/merkl/IDistributor.sol +6 -0
  90. package/contracts/base/interface/notional/INProxy.sol +44 -0
  91. package/contracts/base/interface/notional/IPrimeToken.sol +6 -0
  92. package/contracts/base/interface/venus/IRewardsDistributor.sol +6 -0
  93. package/contracts/base/interface/weth/IWETH.sol +39 -0
  94. package/contracts/base/ipor/Erc4626BalanceFuse.sol +54 -0
  95. package/contracts/base/ipor/Erc4626SupplyFuse.sol +134 -0
  96. package/contracts/base/noop/NoopStrategyUpgradeable.sol +90 -0
  97. package/contracts/base/upgradability/BaseUpgradeabilityProxy.sol +60 -0
  98. package/contracts/base/upgradability/BaseUpgradeableStrategy.sol +144 -0
  99. package/contracts/base/upgradability/BaseUpgradeableStrategyStorage.sol +284 -0
  100. package/contracts/base/upgradability/IUpgradable.sol +7 -0
  101. package/contracts/base/upgradability/ReentrancyGuardUpgradeable.sol +51 -0
  102. package/contracts/base/upgradability/StrategyProxy.sol +34 -0
  103. package/contracts/strategies/aura/AuraStrategy.sol +403 -0
  104. package/contracts/strategies/aura/AuraStrategyMainnet_MORE_GYD.sol +32 -0
  105. package/contracts/strategies/aura/AuraStrategyMainnet_sUSDe_GYD.sol +31 -0
  106. package/contracts/strategies/aura/AuraStrategyMainnet_waFRAX_sFRAX.sol +31 -0
  107. package/contracts/strategies/aura/AuraStrategyMainnet_waGHO_GYD.sol +31 -0
  108. package/contracts/strategies/aura/AuraStrategyMainnet_waUSDC_GHO.sol +32 -0
  109. package/contracts/strategies/aura/AuraStrategyMainnet_waUSDC_GYD.sol +31 -0
  110. package/contracts/strategies/aura/AuraStrategyMainnet_waUSDT_GYD.sol +31 -0
  111. package/contracts/strategies/aura/AuraStrategyMainnet_wstETH_GYD.sol +31 -0
  112. package/contracts/strategies/camelot/CamelotV3Strategy.sol +304 -0
  113. package/contracts/strategies/camelot/CamelotV3StrategyMainnet_ARB_USDC.sol +28 -0
  114. package/contracts/strategies/camelot/CamelotV3StrategyMainnet_ETH_USDC.sol +28 -0
  115. package/contracts/strategies/camelot/CamelotV3StrategyMainnet_ETH_USDT.sol +28 -0
  116. package/contracts/strategies/camelot/CamelotV3StrategyMainnet_GMX_ETH.sol +28 -0
  117. package/contracts/strategies/camelot/CamelotV3StrategyMainnet_GRAIL_ETH.sol +28 -0
  118. package/contracts/strategies/camelot/CamelotV3StrategyMainnet_USDC_USDT.sol +28 -0
  119. package/contracts/strategies/camelot/CamelotV3StrategyMainnet_WBTC_ETH.sol +28 -0
  120. package/contracts/strategies/dolomite/DolomiteLendStrategy.sol +273 -0
  121. package/contracts/strategies/dolomite/DolomiteLendStrategyMainnet_DAI.sol +26 -0
  122. package/contracts/strategies/dolomite/DolomiteLendStrategyMainnet_GMX.sol +26 -0
  123. package/contracts/strategies/dolomite/DolomiteLendStrategyMainnet_USDC.sol +26 -0
  124. package/contracts/strategies/dolomite/DolomiteLendStrategyMainnet_USDCe.sol +26 -0
  125. package/contracts/strategies/dolomite/DolomiteLendStrategyMainnet_USDT.sol +26 -0
  126. package/contracts/strategies/dolomite/DolomiteLendStrategyMainnet_WBTC.sol +26 -0
  127. package/contracts/strategies/dolomite/DolomiteLendStrategyMainnet_WETH.sol +26 -0
  128. package/contracts/strategies/fluid/FluidLendStrategy.sol +241 -0
  129. package/contracts/strategies/fluid/FluidLendStrategyMainnet_ETH.sol +25 -0
  130. package/contracts/strategies/fluid/FluidLendStrategyMainnet_USDC.sol +25 -0
  131. package/contracts/strategies/fluid/FluidLendStrategyMainnet_USDT.sol +25 -0
  132. package/contracts/strategies/gmx/GMXStrategy.sol +472 -0
  133. package/contracts/strategies/gmx/GMXStrategyMainnet_WBTC.sol +25 -0
  134. package/contracts/strategies/gmx/GMXViewer.sol +110 -0
  135. package/contracts/strategies/notional/NotionalStrategy.sol +223 -0
  136. package/contracts/strategies/notional/NotionalStrategyMainnet_nETH.sol +27 -0
  137. package/contracts/strategies/notional/NotionalStrategyMainnet_nUSDC.sol +27 -0
  138. package/contracts/strategies/notional/NotionalStrategyMainnet_nUSDT.sol +27 -0
  139. package/contracts/strategies/notional/NotionalStrategyMainnet_nwstETH.sol +27 -0
  140. package/contracts/strategies/venus/VenusFoldStrategy.sol +591 -0
  141. package/contracts/strategies/venus/VenusFoldStrategyMainnet_ARB.sol +32 -0
  142. package/contracts/strategies/venus/VenusFoldStrategyMainnet_ETH_core.sol +32 -0
  143. package/contracts/strategies/venus/VenusFoldStrategyMainnet_ETH_lsd.sol +32 -0
  144. package/contracts/strategies/venus/VenusFoldStrategyMainnet_USDC.sol +32 -0
  145. package/contracts/strategies/venus/VenusFoldStrategyMainnet_USDT.sol +32 -0
  146. package/contracts/strategies/venus/VenusFoldStrategyMainnet_WBTC.sol +32 -0
  147. package/hardhat.config.js +60 -0
  148. package/index.js +42 -0
  149. package/package.json +39 -6
  150. package/scripts/01-deploy-vault-regular-with-upgradable-strategy.js +41 -0
  151. package/scripts/02-deploy-vault-regular.js +35 -0
  152. package/scripts/03-deploy-upgradable-strategy.js +40 -0
  153. package/scripts/04-deploy-new-implementation.js +24 -0
  154. package/scripts/05-deploy-GMXViewer.js +17 -0
  155. package/scripts/06-deploy-GMXVault.js +49 -0
  156. package/scripts/07-deploy-ipor-fuses.js +29 -0
  157. package/scripts/08-deploy-drip.js +20 -0
  158. package/scripts/README.md +55 -0
  159. package/scripts/utils.js +22 -0
  160. package/test/aura/more-gyd.js +140 -0
  161. package/test/aura/susde-gyd.js +140 -0
  162. package/test/aura/wafrax-sfrax.js +140 -0
  163. package/test/aura/wagho-gyd.js +140 -0
  164. package/test/aura/wausdc-gho.js +141 -0
  165. package/test/aura/wausdc-gyd.js +140 -0
  166. package/test/aura/wausdt-gyd.js +140 -0
  167. package/test/aura/wsteth-gyd.js +138 -0
  168. package/test/camelot/arb-usdc.js +125 -0
  169. package/test/camelot/eth-usdc.js +125 -0
  170. package/test/camelot/eth-usdt.js +125 -0
  171. package/test/camelot/gmx-eth.js +125 -0
  172. package/test/camelot/grail-eth.js +125 -0
  173. package/test/camelot/usdc-usdt.js +125 -0
  174. package/test/camelot/wbtc-eth.js +125 -0
  175. package/test/dolomite/dai.js +127 -0
  176. package/test/dolomite/gmx.js +134 -0
  177. package/test/dolomite/usdc.js +127 -0
  178. package/test/dolomite/usdce.js +127 -0
  179. package/test/dolomite/usdt.js +127 -0
  180. package/test/dolomite/wbtc.js +127 -0
  181. package/test/dolomite/weth.js +127 -0
  182. package/test/fluid/eth.js +127 -0
  183. package/test/fluid/usdc.js +134 -0
  184. package/test/fluid/usdt.js +134 -0
  185. package/test/gmx/wbtc.js +184 -0
  186. package/test/notional/neth.js +133 -0
  187. package/test/notional/nusdc.js +133 -0
  188. package/test/notional/nusdt.js +133 -0
  189. package/test/notional/nwsteth.js +133 -0
  190. package/test/test-config.js +28 -0
  191. package/test/utilities/Utils.js +96 -0
  192. package/test/utilities/hh-utils.js +248 -0
  193. package/test/utilities/make-vault.js +16 -0
  194. package/test/venus/arb.js +135 -0
  195. package/test/venus/eth-core.js +133 -0
  196. package/test/venus/eth-lsd.js +133 -0
  197. package/test/venus/usdc.js +133 -0
  198. package/test/venus/usdt.js +133 -0
  199. package/test/venus/wbtc.js +133 -0
@@ -0,0 +1,261 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity 0.8.26;
3
+
4
+ interface IERC4626 {
5
+
6
+ // ========================= Events =========================
7
+
8
+ /**
9
+ * Caller has exchanged assets for shares, and transferred those shares to owner.
10
+ *
11
+ * MUST be emitted when tokens are deposited into the Vault via the mint and deposit methods.
12
+ */
13
+ event Deposit(
14
+ address indexed sender,
15
+ address indexed receiver,
16
+ uint256 assets,
17
+ uint256 shares
18
+ );
19
+
20
+ /**
21
+ * Caller has exchanged shares, owned by owner, for assets, and transferred those assets to receiver.
22
+ *
23
+ * MUST be emitted when shares are withdrawn from the Vault in ERC4626.redeem or ERC4626.withdraw methods.
24
+ */
25
+ event Withdraw(
26
+ address indexed sender,
27
+ address indexed receiver,
28
+ address indexed owner,
29
+ uint256 assets,
30
+ uint256 shares
31
+ );
32
+
33
+ // ========================= Functions =========================
34
+
35
+ /**
36
+ * @return assetTokenAddress The address of the underlying token used for the Vault for accounting, depositing, and withdrawing.
37
+ */
38
+ function asset() external view returns (address assetTokenAddress);
39
+
40
+ /**
41
+ * @return totalManagedAssets Total amount of the underlying asset that is “managed” by Vault. SHOULD include any compounding that
42
+ * occurs from yield. MUST be inclusive of any fees that are charged against assets in the Vault.
43
+ */
44
+ function totalAssets() external view returns (uint256 totalManagedAssets);
45
+
46
+ /**
47
+ * @return assetsPerUnitShare The amount of underlying the Vault would exchange for 1 unit of shares, in an ideal scenario where all
48
+ * the conditions are met. MUST NOT be inclusive of any fees that are charged against assets in the Vault.
49
+ * MUST NOT show any variations depending on the caller. MUST NOT reflect slippage or other on-chain
50
+ * conditions, when performing the actual exchange. MUST NOT revert unless due to integer overflow caused
51
+ * by an unreasonably large input. MUST round down towards 0. This calculation MAY NOT reflect the
52
+ * “per-user” price-per-share, and instead should reflect the “average-user’s” price-per-share, meaning
53
+ * what the average user should expect to see when exchanging to and from. This function should normally
54
+ * return more than `10 ** underlying().decimals`.
55
+ */
56
+ function assetsPerShare() external view returns (uint256 assetsPerUnitShare);
57
+
58
+ /**
59
+ * @return assets Total amount of the underlying asset that is “managed” by Vault for the `depositor`. SHOULD include any
60
+ * compounding that occurs from yield. MUST be inclusive of any fees that are charged against assets in the
61
+ * Vault.
62
+ */
63
+ function assetsOf(address depositor) external view returns (uint256 assets);
64
+
65
+ /**
66
+ * Maximum amount of the underlying asset that can be deposited into the Vault for the receiver, through a deposit
67
+ * call. MUST return the maximum amount of assets deposit would allow to be deposited for receiver and not cause a
68
+ * revert, which MUST NOT be higher than the actual maximum that would be accepted (it should underestimate if
69
+ * necessary). This assumes that the user has infinite assets, i.e. MUST NOT rely on balanceOf of asset. MUST factor
70
+ * in both global and user-specific limits, like if deposits are entirely disabled (even temporarily) it MUST return
71
+ * 0. MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.
72
+ */
73
+ function maxDeposit(address caller) external view returns (uint256 maxAssets);
74
+
75
+ /**
76
+ * Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given current
77
+ * on-chain conditions.
78
+ *
79
+ * MUST return as close to and no more than the exact amount of Vault shares that would be
80
+ * minted in a deposit call in the same transaction. I.e. deposit should return the same or more shares as
81
+ * previewDeposit if called in the same transaction. MUST NOT account for deposit limits like those returned from
82
+ * maxDeposit and should always act as though the deposit would be accepted, regardless if the user has enough
83
+ * tokens approved, etc.
84
+ *
85
+ * MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
86
+ *
87
+ * MUST NOT revert due to vault specific user/global limits. MAY revert due to other conditions that would also
88
+ * cause deposit to revert.
89
+ *
90
+ * Note that any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in
91
+ * share price or some other type of condition, meaning the depositor will lose assets by depositing.
92
+ */
93
+ function previewDeposit(uint256 assets) external view returns (uint256 shares);
94
+
95
+ /**
96
+ * Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.
97
+ *
98
+ * MUST emit the Deposit event.
99
+ *
100
+ * MUST support ERC-20 approve / transferFrom on asset as a deposit flow. MAY support an additional flow in which
101
+ * the underlying tokens are owned by the Vault contract before the deposit execution, and are accounted for during
102
+ * deposit.
103
+ *
104
+ * MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not
105
+ * approving enough underlying tokens to the Vault contract, etc).
106
+ *
107
+ * Note that most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
108
+ */
109
+ function deposit(uint256 assets, address receiver) external returns (uint256 shares);
110
+
111
+ /**
112
+ * Maximum amount of shares that can be minted from the Vault for the receiver, through a mint call.
113
+ *
114
+ * MUST return the maximum amount of shares mint would allow to be deposited to receiver and not cause a revert,
115
+ * which MUST NOT be higher than the actual maximum that would be accepted (it should underestimate if necessary).
116
+ * This assumes that the user has infinite assets, i.e. MUST NOT rely on balanceOf of asset.
117
+ *
118
+ * MUST factor in both global and user-specific limits, like if mints are entirely disabled (even temporarily) it
119
+ * MUST return 0.
120
+ *
121
+ * MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.
122
+ */
123
+ function maxMint(address caller) external view returns (uint256 maxShares);
124
+
125
+ /**
126
+ * Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given current
127
+ * on-chain conditions.
128
+ *
129
+ * MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call in
130
+ * the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the same
131
+ * transaction.
132
+ *
133
+ * MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint would
134
+ * be accepted, regardless if the user has enough tokens approved, etc.
135
+ *
136
+ * MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
137
+ *
138
+ * MUST NOT revert due to vault specific user/global limits. MAY revert due to other conditions that would also
139
+ * cause mint to revert.
140
+ *
141
+ * Note that any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in
142
+ * share price or some other type of condition, meaning the depositor will lose assets by minting.
143
+ */
144
+ function previewMint(uint256 shares) external view returns (uint256 assets);
145
+
146
+ /**
147
+ * Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.
148
+ *
149
+ * MUST emit the Deposit event.
150
+ *
151
+ * MUST support ERC-20 approve / transferFrom on asset as a mint flow. MAY support an additional flow in which the
152
+ * underlying tokens are owned by the Vault contract before the mint execution, and are accounted for during mint.
153
+ *
154
+ * MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not
155
+ * approving enough underlying tokens to the Vault contract, etc).
156
+ *
157
+ * Note that most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
158
+ */
159
+ function mint(uint256 shares, address receiver) external returns (uint256 assets);
160
+
161
+ /**
162
+ * Maximum amount of the underlying asset that can be withdrawn from the owner balance in the Vault, through a
163
+ * withdraw call.
164
+ *
165
+ * MUST return the maximum amount of assets that could be transferred from owner through withdraw and not cause a
166
+ * revert, which MUST NOT be higher than the actual maximum that would be accepted (it should underestimate if
167
+ * necessary).
168
+ *
169
+ * MUST factor in both global and user-specific limits, like if withdrawals are entirely disabled (even temporarily)
170
+ * it MUST return 0.
171
+ */
172
+ function maxWithdraw(address caller) external view returns (uint256 maxAssets);
173
+
174
+ /**
175
+ * Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block, given
176
+ * current on-chain conditions.
177
+ *
178
+ * MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw
179
+ * call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if called
180
+ * in the same transaction.
181
+ *
182
+ * MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though the
183
+ * withdrawal would be accepted, regardless if the user has enough shares, etc.
184
+ *
185
+ * MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
186
+ *
187
+ * MUST NOT revert due to vault specific user/global limits. MAY revert due to other conditions that would also
188
+ * cause withdraw to revert.
189
+ *
190
+ * Note that any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage
191
+ * in share price or some other type of condition, meaning the depositor will lose assets by depositing.
192
+ */
193
+ function previewWithdraw(uint256 assets) external view returns (uint256 shares);
194
+
195
+ /**
196
+ * Burns shares from owner and sends exactly assets of underlying tokens to receiver.
197
+ *
198
+ * MUST emit the Withdraw event.
199
+ *
200
+ * MUST support a withdraw flow where the shares are burned from owner directly where owner is msg.sender or
201
+ * msg.sender has ERC-20 approval over the shares of owner. MAY support an additional flow in which the shares are
202
+ * transferred to the Vault contract before the withdraw execution, and are accounted for during withdraw.
203
+ *
204
+ * MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner not
205
+ * having enough shares, etc).
206
+ *
207
+ * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
208
+ * Those methods should be performed separately.
209
+ */
210
+ function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);
211
+
212
+ /**
213
+ * Maximum amount of Vault shares that can be redeemed from the owner balance in the Vault, through a redeem call.
214
+ *
215
+ * MUST return the maximum amount of shares that could be transferred from owner through redeem and not cause a
216
+ * revert, which MUST NOT be higher than the actual maximum that would be accepted (it should underestimate if
217
+ * necessary).
218
+ *
219
+ * MUST factor in both global and user-specific limits, like if redemption is entirely disabled (even temporarily)
220
+ * it MUST return 0.
221
+ */
222
+ function maxRedeem(address caller) external view returns (uint256 maxShares);
223
+
224
+ /**
225
+ * Allows an on-chain or off-chain user to simulate the effects of their redemption at the current block, given
226
+ * current on-chain conditions.
227
+ *
228
+ * MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call in
229
+ * the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the same
230
+ * transaction.
231
+ *
232
+ * MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the
233
+ * redemption would be accepted, regardless if the user has enough shares, etc.
234
+ *
235
+ * MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
236
+ *
237
+ * MUST NOT revert due to vault specific user/global limits. MAY revert due to other conditions that would also
238
+ * cause redeem to revert.
239
+ *
240
+ * Note that any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in
241
+ * share price or some other type of condition, meaning the depositor will lose assets by redeeming.
242
+ */
243
+ function previewRedeem(uint256 shares) external view returns (uint256 assets);
244
+
245
+ /**
246
+ * Burns exactly shares from owner and sends assets of underlying tokens to receiver.
247
+ *
248
+ * MUST emit the Withdraw event.
249
+ *
250
+ * MUST support a redeem flow where the shares are burned from owner directly where owner is msg.sender or
251
+ * msg.sender has ERC-20 approval over the shares of owner. MAY support an additional flow in which the shares are
252
+ * transferred to the Vault contract before the redeem execution, and are accounted for during redeem.
253
+ *
254
+ * MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner not
255
+ * having enough shares, etc).
256
+ *
257
+ * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
258
+ * Those methods should be performed separately.
259
+ */
260
+ function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets);
261
+ }
@@ -0,0 +1,37 @@
1
+ // SPDX-License-Identifier: Unlicense
2
+ pragma solidity 0.8.26;
3
+
4
+ interface IGMXStrategy {
5
+
6
+ /// @notice declared as public so child contract can call it
7
+ function isUnsalvageableToken(address token) external view returns (bool);
8
+
9
+ function salvageToken(address recipient, address token, uint amount) external;
10
+
11
+ function governance() external view returns (address);
12
+
13
+ function controller() external view returns (address);
14
+
15
+ function underlying() external view returns (address);
16
+
17
+ function vault() external view returns (address);
18
+
19
+ function withdrawAllToVault() external returns(bytes32);
20
+
21
+ function withdrawToVault(uint256 _amount) external returns(bytes32);
22
+
23
+ function investedUnderlyingBalance() external view returns (uint256);
24
+
25
+ function doHardWork() external returns(bytes32);
26
+
27
+ function depositArbCheck() external view returns (bool);
28
+
29
+ function strategist() external view returns (address);
30
+
31
+ /**
32
+ * @return The value of any accumulated rewards that are under control by the strategy. Each index corresponds with
33
+ * the tokens in `rewardTokens`. This function is not a `view`, because some protocols, like Curve, need
34
+ * writeable functions to get the # of claimable reward tokens
35
+ */
36
+ function getRewardPoolValues() external returns (uint256[] memory);
37
+ }
@@ -0,0 +1,6 @@
1
+ //SPDX-License-Identifier: Unlicense
2
+ pragma solidity 0.8.26;
3
+
4
+ interface IGlobalIncentivesHelper {
5
+ function notifyPools(address[] calldata tokens, uint256[] calldata totals, uint256 timestamp) external;
6
+ }
@@ -0,0 +1,70 @@
1
+ // SPDX-License-Identifier: Unlicense
2
+ pragma solidity 0.8.26;
3
+
4
+ interface IPotPool {
5
+
6
+ function initializePotPool(
7
+ address[] calldata _rewardTokens,
8
+ address _lpToken,
9
+ uint256 _duration,
10
+ address[] calldata _rewardDistribution,
11
+ address _storage
12
+ ) external;
13
+
14
+ function lpToken() external view returns (address);
15
+
16
+ function duration() external view returns (uint256);
17
+
18
+ function stakedBalanceOf(address _user) external view returns (uint);
19
+
20
+ function smartContractStakers(address _user) external view returns (bool);
21
+
22
+ function rewardTokens(uint _index) external view returns (address);
23
+
24
+ function getRewardTokens() external view returns (address[] memory);
25
+
26
+ function periodFinishForToken(address _rewardToken) external view returns (uint);
27
+
28
+ function rewardRateForToken(address _rewardToken) external view returns (uint);
29
+
30
+ function lastUpdateTimeForToken(address _rewardToken) external view returns (uint);
31
+
32
+ function rewardPerTokenStoredForToken(address _rewardToken) external view returns (uint);
33
+
34
+ function userRewardPerTokenPaidForToken(address _rewardToken, address _user) external view returns (uint);
35
+
36
+ function rewardsForToken(address _rewardToken, address _user) external view returns (uint);
37
+
38
+ function lastTimeRewardApplicable(address _rewardToken) external view returns (uint256);
39
+
40
+ function rewardPerToken(address _rewardToken) external view returns (uint256);
41
+
42
+ function stake(uint256 _amount) external;
43
+
44
+ function withdraw(uint256 _amount) external;
45
+
46
+ function exit() external;
47
+
48
+ /**
49
+ * A push mechanism for accounts that have not claimed their rewards for a long time. The implementation is
50
+ * semantically analogous to getReward(), but uses a push pattern instead of pull pattern.
51
+ */
52
+ function pushAllRewards(address _recipient) external;
53
+
54
+ function getAllRewards() external;
55
+
56
+ function getReward(address _rewardToken) external;
57
+
58
+ function addRewardToken(address _rewardToken) external;
59
+
60
+ function removeRewardToken(address _rewardToken) external;
61
+
62
+ /**
63
+ * @return If the return value is MAX_UINT256, it means that the specified reward token is not in the list
64
+ */
65
+ function getRewardTokenIndex(address _rewardToken) external view returns (uint256);
66
+
67
+ function notifyTargetRewardAmount(address _rewardToken, uint256 _reward) external;
68
+
69
+ function rewardTokensLength() external view returns (uint256);
70
+ }
@@ -0,0 +1,9 @@
1
+ // SPDX-License-Identifier: Unlicense
2
+ pragma solidity 0.8.26;
3
+
4
+ interface IProfitSharingReceiver {
5
+
6
+ function governance() external view returns (address);
7
+
8
+ function withdrawTokens(address[] calldata _tokens) external;
9
+ }
@@ -0,0 +1,57 @@
1
+ // SPDX-License-Identifier: Unlicense
2
+ pragma solidity 0.8.26;
3
+
4
+ /**
5
+ * @dev A routing contract that is responsible for taking the harvested gains and routing them into FARM and additional
6
+ * buyback tokens for the corresponding strategy
7
+ */
8
+ interface IRewardForwarder {
9
+
10
+ function store() external view returns (address);
11
+
12
+ function governance() external view returns (address);
13
+
14
+ /**
15
+ * @dev This function sends converted `_buybackTokens` to `msg.sender`. The returned amounts will match the
16
+ * `amounts` return value. The fee amounts are converted to the profit sharing token and sent to the proper
17
+ * addresses (profit sharing, strategist, and governance (platform)).
18
+ *
19
+ * @param _token the token that will be compounded or sold into the profit sharing token for the Harvest
20
+ * collective (users that stake iFARM)
21
+ * @param _profitSharingFee the amount of `_token` that will be sold into the profit sharing token
22
+ * @param _strategistFee the amount of `_token` that will be sold into the profit sharing token for the
23
+ * strategist
24
+ * @param _platformFee the amount of `_token` that will be sold into the profit sharing token for the Harvest
25
+ * treasury
26
+ * @param _buybackTokens the output tokens that `_buyBackAmounts` should be swapped to (outputToken)
27
+ * @param _buybackAmounts the amounts of `_token` that will be bought into more `_buybackTokens` token
28
+ * @return amounts The amounts that were purchased of _buybackTokens
29
+ */
30
+ function notifyFeeAndBuybackAmounts(
31
+ address _token,
32
+ uint256 _profitSharingFee,
33
+ uint256 _strategistFee,
34
+ uint256 _platformFee,
35
+ address[] calldata _buybackTokens,
36
+ uint256[] calldata _buybackAmounts
37
+ ) external returns (uint[] memory amounts);
38
+
39
+ /**
40
+ * @dev This function converts the fee amounts to the profit sharing token and sends them to the proper addresses
41
+ * (profit sharing, strategist, and governance (platform)).
42
+ *
43
+ * @param _token the token that will be compounded or sold into the profit sharing token for the Harvest
44
+ * collective (users that stake iFARM)
45
+ * @param _profitSharingFee the amount of `_token` that will be sold into the profit sharing token
46
+ * @param _strategistFee the amount of `_token` that will be sold into the profit sharing token for the
47
+ * strategist
48
+ * @param _platformFee the amount of `_token` that will be sold into the profit sharing token for the Harvest
49
+ * treasury
50
+ */
51
+ function notifyFee(
52
+ address _token,
53
+ uint256 _profitSharingFee,
54
+ uint256 _strategistFee,
55
+ uint256 _platformFee
56
+ ) external;
57
+ }
@@ -0,0 +1,37 @@
1
+ // SPDX-License-Identifier: Unlicense
2
+ pragma solidity 0.8.26;
3
+
4
+ interface IStrategy {
5
+
6
+ /// @notice declared as public so child contract can call it
7
+ function isUnsalvageableToken(address token) external view returns (bool);
8
+
9
+ function salvageToken(address recipient, address token, uint amount) external;
10
+
11
+ function governance() external view returns (address);
12
+
13
+ function controller() external view returns (address);
14
+
15
+ function underlying() external view returns (address);
16
+
17
+ function vault() external view returns (address);
18
+
19
+ function withdrawAllToVault() external;
20
+
21
+ function withdrawToVault(uint256 _amount) external;
22
+
23
+ function investedUnderlyingBalance() external view returns (uint256);
24
+
25
+ function doHardWork() external;
26
+
27
+ function depositArbCheck() external view returns (bool);
28
+
29
+ function strategist() external view returns (address);
30
+
31
+ /**
32
+ * @return The value of any accumulated rewards that are under control by the strategy. Each index corresponds with
33
+ * the tokens in `rewardTokens`. This function is not a `view`, because some protocols, like Curve, need
34
+ * writeable functions to get the # of claimable reward tokens
35
+ */
36
+ function getRewardPoolValues() external returns (uint256[] memory);
37
+ }
@@ -0,0 +1,21 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity 0.8.26;
3
+
4
+ interface IUniversalLiquidator {
5
+ event Swap(
6
+ address indexed sellToken,
7
+ address indexed buyToken,
8
+ address indexed receiver,
9
+ address initiator,
10
+ uint256 sellAmount,
11
+ uint256 minBuyAmount
12
+ );
13
+
14
+ function swap(
15
+ address _sellToken,
16
+ address _buyToken,
17
+ uint256 _sellAmount,
18
+ uint256 _minBuyAmount,
19
+ address _receiver
20
+ ) external returns (uint256);
21
+ }
@@ -0,0 +1,20 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity 0.8.26;
3
+
4
+ interface IUniversalLiquidatorRegistry {
5
+
6
+ function setPath(bytes32 _dex, address[] memory _paths) external;
7
+
8
+ function setIntermediateToken(address[] memory _token) external;
9
+
10
+ function addDex(bytes32 _name, address _address) external;
11
+
12
+ function changeDexAddress(bytes32 _name, address _address) external;
13
+
14
+ function getAllDexes() external view returns (bytes32[] memory);
15
+
16
+ function getAllIntermediateTokens()
17
+ external
18
+ view
19
+ returns (address[] memory);
20
+ }
@@ -0,0 +1,9 @@
1
+ // SPDX-License-Identifier: Unlicense
2
+ pragma solidity 0.8.26;
3
+
4
+ interface IUpgradeSource {
5
+
6
+ function shouldUpgrade() external view returns (bool, address);
7
+
8
+ function finalizeUpgrade() external;
9
+ }
@@ -0,0 +1,58 @@
1
+ // SPDX-License-Identifier: Unlicense
2
+ pragma solidity 0.8.26;
3
+
4
+ interface IVault {
5
+
6
+ function initializeVault(
7
+ address _storage,
8
+ address _underlying,
9
+ uint256 _toInvestNumerator,
10
+ uint256 _toInvestDenominator
11
+ ) external;
12
+
13
+ function balanceOf(address _holder) external view returns (uint256);
14
+
15
+ function underlyingBalanceInVault() external view returns (uint256);
16
+
17
+ function underlyingBalanceWithInvestment() external view returns (uint256);
18
+
19
+ function governance() external view returns (address);
20
+
21
+ function controller() external view returns (address);
22
+
23
+ function underlying() external view returns (address);
24
+
25
+ function underlyingUnit() external view returns (uint);
26
+
27
+ function strategy() external view returns (address);
28
+
29
+ function setStrategy(address _strategy) external;
30
+
31
+ function announceStrategyUpdate(address _strategy) external;
32
+
33
+ function setVaultFractionToInvest(uint256 _numerator, uint256 _denominator) external;
34
+
35
+ function deposit(uint256 _amount) external;
36
+ function deposit(uint256 _amount, address _receiver) external;
37
+
38
+ function depositFor(uint256 _amount, address _holder) external;
39
+
40
+ function withdrawAll() external;
41
+
42
+ function withdraw(uint256 _numberOfShares) external;
43
+
44
+ function getPricePerFullShare() external view returns (uint256);
45
+
46
+ function underlyingBalanceWithInvestmentForHolder(address _holder) view external returns (uint256);
47
+
48
+ /**
49
+ * The total amount available to be deposited from this vault into the strategy, while adhering to the
50
+ * `vaultFractionToInvestNumerator` and `vaultFractionToInvestDenominator` rules
51
+ */
52
+ function availableToInvestOut() external view returns (uint256);
53
+
54
+ /**
55
+ * This should be callable only by the controller (by the hard worker) or by governance
56
+ */
57
+ function doHardWork() external;
58
+ }
@@ -0,0 +1,71 @@
1
+ // SPDX-License-Identifier: Unlicense
2
+ pragma solidity 0.8.26;
3
+
4
+ interface IVaultGMX {
5
+
6
+ struct PendingAction {
7
+ bool pending;
8
+ address sender;
9
+ address receiver;
10
+ uint256 amountIn;
11
+ }
12
+
13
+ function initializeVault(
14
+ address _storage,
15
+ address _underlying,
16
+ uint256 _toInvestNumerator,
17
+ uint256 _toInvestDenominator
18
+ ) external;
19
+
20
+ function balanceOf(address _holder) external view returns (uint256);
21
+
22
+ function underlyingBalanceInVault() external view returns (uint256);
23
+
24
+ function underlyingBalanceWithInvestment() external view returns (uint256);
25
+
26
+ function governance() external view returns (address);
27
+
28
+ function controller() external view returns (address);
29
+
30
+ function underlying() external view returns (address);
31
+
32
+ function underlyingUnit() external view returns (uint);
33
+
34
+ function strategy() external view returns (address);
35
+
36
+ function setStrategy(address _strategy) external;
37
+
38
+ function announceStrategyUpdate(address _strategy) external;
39
+
40
+ function setVaultFractionToInvest(uint256 _numerator, uint256 _denominator) external;
41
+
42
+ function deposit(uint256 _amount) external;
43
+ function deposit(uint256 _amount, address _receiver) external;
44
+
45
+ function depositFor(uint256 _amount, address _holder) external;
46
+
47
+ function withdrawAll() external;
48
+
49
+ function withdraw(uint256 _numberOfShares) external;
50
+
51
+ function getPricePerFullShare() external view returns (uint256);
52
+
53
+ function underlyingBalanceWithInvestmentForHolder(address _holder) view external returns (uint256);
54
+
55
+ /**
56
+ * The total amount available to be deposited from this vault into the strategy, while adhering to the
57
+ * `vaultFractionToInvestNumerator` and `vaultFractionToInvestDenominator` rules
58
+ */
59
+ function availableToInvestOut() external view returns (uint256);
60
+
61
+ /**
62
+ * This should be callable only by the controller (by the hard worker) or by governance
63
+ */
64
+ function doHardWork() external;
65
+
66
+ function finalizeDeposit(bool success, bytes32 key, uint256 amount) external;
67
+ function finalizeWithdrawal(bool success, bytes32 key, uint256 amount) external;
68
+
69
+ function pendingDeposits(bytes32 key) external view returns (PendingAction memory);
70
+ function pendingWithdrawals(bytes32 key) external view returns (PendingAction memory);
71
+ }