@harvest-finance/harvest-strategy-arbitrum 0.0.1-security → 1.0.0

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 +38 -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,114 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+ // This program is free software: you can redistribute it and/or modify
3
+ // it under the terms of the GNU General Public License as published by
4
+ // the Free Software Foundation, either version 3 of the License, or
5
+ // (at your option) any later version.
6
+
7
+ // This program is distributed in the hope that it will be useful,
8
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
+ // GNU General Public License for more details.
11
+
12
+ // You should have received a copy of the GNU General Public License
13
+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
14
+
15
+ pragma solidity 0.8.26;
16
+
17
+
18
+ /**
19
+ * @dev Base minter interface, applicable to Mainnet minter or L2 pseudo minters.
20
+ */
21
+ interface IBalancerMinter {
22
+ event Minted(address indexed recipient, address gauge, uint256 minted);
23
+
24
+ /**
25
+ * @notice Returns the address of the Balancer Governance Token
26
+ */
27
+ function getBalancerToken() external view returns (address);
28
+
29
+ /**
30
+ * @notice Mint everything which belongs to `msg.sender` and send to them
31
+ * @param gauge `LiquidityGauge` address to get mintable amount from
32
+ */
33
+ function mint(address gauge) external returns (uint256);
34
+
35
+ /**
36
+ * @notice Mint everything which belongs to `msg.sender` across multiple gauges
37
+ * @param gauges List of `LiquidityGauge` addresses
38
+ */
39
+ function mintMany(address[] calldata gauges) external returns (uint256);
40
+
41
+ /**
42
+ * @notice Mint tokens for `user`
43
+ * @dev Only possible when `msg.sender` has been approved by `user` to mint on their behalf
44
+ * @param gauge `LiquidityGauge` address to get mintable amount from
45
+ * @param user Address to mint to
46
+ */
47
+ function mintFor(address gauge, address user) external returns (uint256);
48
+
49
+ /**
50
+ * @notice Mint tokens for `user` across multiple gauges
51
+ * @dev Only possible when `msg.sender` has been approved by `user` to mint on their behalf
52
+ * @param gauges List of `LiquidityGauge` addresses
53
+ * @param user Address to mint to
54
+ */
55
+ function mintManyFor(address[] calldata gauges, address user) external returns (uint256);
56
+
57
+ /**
58
+ * @notice The total number of tokens minted for `user` from `gauge`
59
+ */
60
+ function minted(address user, address gauge) external view returns (uint256);
61
+
62
+ /**
63
+ * @notice Whether `minter` is approved to mint tokens for `user`
64
+ */
65
+ function getMinterApproval(address minter, address user) external view returns (bool);
66
+
67
+ /**
68
+ * @notice Set whether `minter` is approved to mint tokens on your behalf
69
+ */
70
+ function setMinterApproval(address minter, bool approval) external;
71
+
72
+ /**
73
+ * @notice Set whether `minter` is approved to mint tokens on behalf of `user`, who has signed a message authorizing
74
+ * them.
75
+ */
76
+ function setMinterApprovalWithSignature(
77
+ address minter,
78
+ bool approval,
79
+ address user,
80
+ uint256 deadline,
81
+ uint8 v,
82
+ bytes32 r,
83
+ bytes32 s
84
+ ) external;
85
+
86
+ // The below functions are near-duplicates of functions available above.
87
+ // They are included for ABI compatibility with snake_casing as used in vyper contracts.
88
+ // solhint-disable func-name-mixedcase
89
+
90
+ /**
91
+ * @notice Whether `minter` is approved to mint tokens for `user`
92
+ */
93
+ function allowed_to_mint_for(address minter, address user) external view returns (bool);
94
+
95
+ /**
96
+ * @notice Mint everything which belongs to `msg.sender` across multiple gauges
97
+ * @dev This function is not recommended as `mintMany()` is more flexible and gas efficient
98
+ * @param gauges List of `LiquidityGauge` addresses
99
+ */
100
+ function mint_many(address[8] calldata gauges) external;
101
+
102
+ /**
103
+ * @notice Mint tokens for `user`
104
+ * @dev Only possible when `msg.sender` has been approved by `user` to mint on their behalf
105
+ * @param gauge `LiquidityGauge` address to get mintable amount from
106
+ * @param user Address to mint to
107
+ */
108
+ function mint_for(address gauge, address user) external;
109
+
110
+ /**
111
+ * @notice Toggle whether `minter` is approved to mint tokens for `user`
112
+ */
113
+ function toggle_approve_mint(address minter) external;
114
+ }
@@ -0,0 +1,7 @@
1
+ //SPDX-License-Identifier: Unlicense
2
+ pragma solidity 0.8.26;
3
+
4
+ interface IGyroPool {
5
+ function getPrice() external view returns(uint256);
6
+ function getActualSupply() external view returns(uint256);
7
+ }
@@ -0,0 +1,184 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+ // This program is free software: you can redistribute it and/or modify
3
+ // it under the terms of the GNU General Public License as published by
4
+ // the Free Software Foundation, either version 3 of the License, or
5
+ // (at your option) any later version.
6
+
7
+ // This program is distributed in the hope that it will be useful,
8
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
+ // GNU General Public License for more details.
11
+
12
+ // You should have received a copy of the GNU General Public License
13
+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
14
+
15
+ pragma solidity 0.8.26;
16
+
17
+ import "./IPoolSwapStructs.sol";
18
+
19
+ interface IBasePool is IPoolSwapStructs {
20
+ /**
21
+ * @dev Called by the Vault when a user calls `IVault.joinPool` to add liquidity to this Pool. Returns how many of
22
+ * each registered token the user should provide, as well as the amount of protocol fees the Pool owes to the Vault.
23
+ * The Vault will then take tokens from `sender` and add them to the Pool's balances, as well as collect
24
+ * the reported amount in protocol fees, which the pool should calculate based on `protocolSwapFeePercentage`.
25
+ *
26
+ * Protocol fees are reported and charged on join events so that the Pool is free of debt whenever new users join.
27
+ *
28
+ * `sender` is the account performing the join (from which tokens will be withdrawn), and `recipient` is the account
29
+ * designated to receive any benefits (typically pool shares). `balances` contains the total balances
30
+ * for each token the Pool registered in the Vault, in the same order that `IVault.getPoolTokens` would return.
31
+ *
32
+ * `lastChangeBlock` is the last block in which *any* of the Pool's registered tokens last changed its total
33
+ * balance.
34
+ *
35
+ * `userData` contains any pool-specific instructions needed to perform the calculations, such as the type of
36
+ * join (e.g., proportional given an amount of pool shares, single-asset, multi-asset, etc.)
37
+ *
38
+ * Contracts implementing this function should check that the caller is indeed the Vault before performing any
39
+ * state-changing operations, such as minting pool shares.
40
+ */
41
+ function onJoinPool(
42
+ bytes32 poolId,
43
+ address sender,
44
+ address recipient,
45
+ uint256[] memory balances,
46
+ uint256 lastChangeBlock,
47
+ uint256 protocolSwapFeePercentage,
48
+ bytes memory userData
49
+ ) external returns (uint256[] memory amountsIn, uint256[] memory dueProtocolFeeAmounts);
50
+
51
+ /**
52
+ * @dev Called by the Vault when a user calls `IVault.exitPool` to remove liquidity from this Pool. Returns how many
53
+ * tokens the Vault should deduct from the Pool's balances, as well as the amount of protocol fees the Pool owes
54
+ * to the Vault. The Vault will then take tokens from the Pool's balances and send them to `recipient`,
55
+ * as well as collect the reported amount in protocol fees, which the Pool should calculate based on
56
+ * `protocolSwapFeePercentage`.
57
+ *
58
+ * Protocol fees are charged on exit events to guarantee that users exiting the Pool have paid their share.
59
+ *
60
+ * `sender` is the account performing the exit (typically the pool shareholder), and `recipient` is the account
61
+ * to which the Vault will send the proceeds. `balances` contains the total token balances for each token
62
+ * the Pool registered in the Vault, in the same order that `IVault.getPoolTokens` would return.
63
+ *
64
+ * `lastChangeBlock` is the last block in which *any* of the Pool's registered tokens last changed its total
65
+ * balance.
66
+ *
67
+ * `userData` contains any pool-specific instructions needed to perform the calculations, such as the type of
68
+ * exit (e.g., proportional given an amount of pool shares, single-asset, multi-asset, etc.)
69
+ *
70
+ * Contracts implementing this function should check that the caller is indeed the Vault before performing any
71
+ * state-changing operations, such as burning pool shares.
72
+ */
73
+ function onExitPool(
74
+ bytes32 poolId,
75
+ address sender,
76
+ address recipient,
77
+ uint256[] memory balances,
78
+ uint256 lastChangeBlock,
79
+ uint256 protocolSwapFeePercentage,
80
+ bytes memory userData
81
+ ) external returns (uint256[] memory amountsOut, uint256[] memory dueProtocolFeeAmounts);
82
+
83
+ /**
84
+ * @dev Returns this Pool's ID, used when interacting with the Vault (to e.g. join the Pool or swap with it).
85
+ */
86
+ function getPoolId() external view returns (bytes32);
87
+
88
+ /**
89
+ * @dev Returns the current swap fee percentage as a 18 decimal fixed point number, so e.g. 1e17 corresponds to a
90
+ * 10% swap fee.
91
+ */
92
+ function getSwapFeePercentage() external view returns (uint256);
93
+
94
+ /**
95
+ * @dev Returns the scaling factors of each of the Pool's tokens. This is an implementation detail that is typically
96
+ * not relevant for outside parties, but which might be useful for some types of Pools.
97
+ */
98
+ function getScalingFactors() external view returns (uint256[] memory);
99
+
100
+ function queryJoin(
101
+ bytes32 poolId,
102
+ address sender,
103
+ address recipient,
104
+ uint256[] memory balances,
105
+ uint256 lastChangeBlock,
106
+ uint256 protocolSwapFeePercentage,
107
+ bytes memory userData
108
+ ) external returns (uint256 bptOut, uint256[] memory amountsIn);
109
+
110
+ function queryExit(
111
+ bytes32 poolId,
112
+ address sender,
113
+ address recipient,
114
+ uint256[] memory balances,
115
+ uint256 lastChangeBlock,
116
+ uint256 protocolSwapFeePercentage,
117
+ bytes memory userData
118
+ ) external returns (uint256 bptIn, uint256[] memory amountsOut);
119
+ }
120
+
121
+ interface ILinearPool is IBasePool {
122
+ /**
123
+ * @dev Returns the Pool's main token.
124
+ */
125
+ function getMainToken() external view returns (address);
126
+
127
+ /**
128
+ * @dev Returns the Pool's wrapped token.
129
+ */
130
+ function getWrappedToken() external view returns (address);
131
+
132
+ /**
133
+ * @dev Returns the index of the Pool's BPT in the Pool tokens array (as returned by IVault.getPoolTokens).
134
+ */
135
+ function getBptIndex() external view returns (uint256);
136
+
137
+ /**
138
+ * @dev Returns the index of the Pool's main token in the Pool tokens array (as returned by IVault.getPoolTokens).
139
+ */
140
+ function getMainIndex() external view returns (uint256);
141
+
142
+ /**
143
+ * @dev Returns the index of the Pool's wrapped token in the Pool tokens array (as returned by
144
+ * IVault.getPoolTokens).
145
+ */
146
+ function getWrappedIndex() external view returns (uint256);
147
+
148
+ /**
149
+ * @dev Returns the Pool's targets for the main token balance. These values have had the main token's scaling
150
+ * factor applied to them.
151
+ */
152
+ function getTargets() external view returns (uint256 lowerTarget, uint256 upperTarget);
153
+
154
+ /**
155
+ * @notice Set the lower and upper bounds of the zero-fee trading range for the main token balance.
156
+ * @dev For a new target range to be valid:
157
+ * - the current balance must be between the current targets (meaning no fees are currently pending)
158
+ * - the current balance must be between the new targets (meaning setting them does not create pending fees)
159
+ *
160
+ * The first requirement could be relaxed, as the LPs actually benefit from the pending fees not being paid out,
161
+ * but being stricter makes analysis easier at little expense.
162
+ *
163
+ * This is a permissioned function, reserved for the pool owner. It will revert when called within a Vault context
164
+ * (i.e. in the middle of a join or an exit).
165
+ *
166
+ * Correct behavior depends on the token balances from the Vault, which may be out of sync with the state of
167
+ * the pool during execution of a Vault hook.
168
+ *
169
+ * See https://forum.balancer.fi/t/reentrancy-vulnerability-scope-expanded/4345 for reference.
170
+ */
171
+ function setTargets(uint256 newLowerTarget, uint256 newUpperTarget) external;
172
+
173
+ /**
174
+ * @notice Set the swap fee percentage.
175
+ * @dev This is a permissioned function, reserved for the pool owner. It will revert when called within a Vault
176
+ * context (i.e. in the middle of a join or an exit).
177
+ *
178
+ * Correct behavior depends on the token balances from the Vault, which may be out of sync with the state of
179
+ * the pool during execution of a Vault hook.
180
+ *
181
+ * See https://forum.balancer.fi/t/reentrancy-vulnerability-scope-expanded/4345 for reference.
182
+ */
183
+ function setSwapFeePercentage(uint256 swapFeePercentage) external;
184
+ }
@@ -0,0 +1,16 @@
1
+ // SPDX-License-Identifier: Unlicense
2
+
3
+ pragma solidity 0.8.26;
4
+
5
+ interface ILinearPoolFactory {
6
+ function create(
7
+ string memory name,
8
+ string memory symbol,
9
+ address mainToken,
10
+ address wrappedToken,
11
+ uint256 upperTarget,
12
+ uint256 swapFeePercentage,
13
+ address owner,
14
+ uint256 protocolId
15
+ ) external returns (address);
16
+ }
@@ -0,0 +1,8 @@
1
+ // SPDX-License-Identifier: Unlicense
2
+
3
+ pragma solidity 0.8.26;
4
+
5
+ interface ILinearPoolRebalancer {
6
+ function rebalance(address recipient) external;
7
+ function rebalanceWithExtraMain(address recipient, uint extraMain) external;
8
+ }
@@ -0,0 +1,56 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+ // This program is free software: you can redistribute it and/or modify
3
+ // it under the terms of the GNU General Public License as published by
4
+ // the Free Software Foundation, either version 3 of the License, or
5
+ // (at your option) any later version.
6
+
7
+ // This program is distributed in the hope that it will be useful,
8
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
+ // GNU General Public License for more details.
11
+
12
+ // You should have received a copy of the GNU General Public License
13
+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
14
+
15
+ pragma solidity 0.8.26;
16
+
17
+ import "../IBVault.sol";
18
+
19
+ interface IPoolSwapStructs {
20
+ // This is not really an interface - it just defines common structs used by other interfaces: IGeneralPool and
21
+ // IMinimalSwapInfoPool.
22
+ //
23
+ // This data structure represents a request for a token swap, where `kind` indicates the swap type ('given in' or
24
+ // 'given out') which indicates whether or not the amount sent by the pool is known.
25
+ //
26
+ // The pool receives `tokenIn` and sends `tokenOut`. `amount` is the number of `tokenIn` tokens the pool will take
27
+ // in, or the number of `tokenOut` tokens the Pool will send out, depending on the given swap `kind`.
28
+ //
29
+ // All other fields are not strictly necessary for most swaps, but are provided to support advanced scenarios in
30
+ // some Pools.
31
+ //
32
+ // `poolId` is the ID of the Pool involved in the swap - this is useful for Pool contracts that implement more than
33
+ // one Pool.
34
+ //
35
+ // The meaning of `lastChangeBlock` depends on the Pool specialization:
36
+ // - Two Token or Minimal Swap Info: the last block in which either `tokenIn` or `tokenOut` changed its total
37
+ // balance.
38
+ // - General: the last block in which *any* of the Pool's registered tokens changed its total balance.
39
+ //
40
+ // `from` is the origin address for the funds the Pool receives, and `to` is the destination address
41
+ // where the Pool sends the outgoing tokens.
42
+ //
43
+ // `userData` is extra data provided by the caller - typically a signature from a trusted party.
44
+ struct SwapRequest {
45
+ IBVault.SwapKind kind;
46
+ address tokenIn;
47
+ address tokenOut;
48
+ uint256 amount;
49
+ // Misc data
50
+ bytes32 poolId;
51
+ uint256 lastChangeBlock;
52
+ address from;
53
+ address to;
54
+ bytes userData;
55
+ }
56
+ }
@@ -0,0 +1,29 @@
1
+ // SPDX-License-Identifier: BSD-3-Clause
2
+ pragma solidity ^0.8.10;
3
+
4
+ abstract contract CTokenInterface {
5
+ address public underlying;
6
+
7
+ function balanceOfUnderlying(address owner) external virtual returns (uint);
8
+
9
+ function borrowBalanceCurrent(
10
+ address account
11
+ ) external virtual returns (uint);
12
+
13
+ function exchangeRateCurrent() external virtual returns (uint);
14
+
15
+ function getCash() external view virtual returns (uint);
16
+
17
+ function totalBorrows() external view virtual returns (uint);
18
+
19
+ function mint(uint mintAmount) external virtual returns (uint);
20
+ function mint() external payable virtual;
21
+
22
+ function redeemUnderlying(uint redeemAmount) external virtual returns (uint);
23
+ function redeem(uint redeemTokens) external virtual returns (uint);
24
+
25
+ function borrow(uint borrowAmount) external virtual returns (uint);
26
+
27
+ function repayBorrow(uint repayAmount) external virtual returns (uint);
28
+ function repayBorrow() external payable virtual;
29
+ }
@@ -0,0 +1,9 @@
1
+ // SPDX-License-Identifier: BSD-3-Clause
2
+ pragma solidity ^0.8.10;
3
+
4
+ interface IComptroller {
5
+ function enterMarkets(address[] memory cTokens) external returns (uint[] memory);
6
+ function borrowCaps(address cToken) external view returns (uint256);
7
+ function supplyCaps(address cToken) external view returns (uint256);
8
+ function getRewardDistributors() external view returns (address[] memory);
9
+ }
@@ -0,0 +1,13 @@
1
+ // SPDX-License-Identifier: Unlicense
2
+ pragma solidity 0.8.26;
3
+
4
+ interface IDepositWithdraw {
5
+ enum BalanceCheckFlag {
6
+ Both,
7
+ From,
8
+ To,
9
+ None
10
+ }
11
+ function depositWeiIntoDefaultAccount(uint256 _marketId, uint256 _amountWei) external;
12
+ function withdrawWeiFromDefaultAccount(uint256 _marketId, uint256 _amountWei, BalanceCheckFlag _balanceCheckFlag) external;
13
+ }
@@ -0,0 +1,15 @@
1
+ // SPDX-License-Identifier: Unlicense
2
+ pragma solidity 0.8.26;
3
+
4
+ interface IDolomiteMargin {
5
+ struct Info {
6
+ address owner; // The address that owns the account
7
+ uint256 number; // A nonce that allows a single address to control many accounts
8
+ }
9
+ struct Wei {
10
+ bool sign; // true if positive
11
+ uint256 value;
12
+ }
13
+ function getAccountWei(Info calldata account, uint256 marketId) external view returns (Wei memory);
14
+ function getMarketIdByTokenAddress(address token) external view returns (uint256);
15
+ }
@@ -0,0 +1,11 @@
1
+ // SPDX-License-Identifier: Unlicense
2
+ pragma solidity 0.8.26;
3
+
4
+ interface IRewardsDistributor {
5
+ struct ClaimInfo {
6
+ uint256 epoch;
7
+ uint256 amount;
8
+ bytes32[] proof;
9
+ }
10
+ function claim(ClaimInfo[] calldata _claimInfo) external;
11
+ }
@@ -0,0 +1,7 @@
1
+ //SPDX-License-Identifier: Unlicense
2
+ pragma solidity 0.8.26;
3
+
4
+ interface IClearing {
5
+ function getSqrtTwapX96(address, uint32) external view returns(uint160);
6
+ function getDepositAmount(address, address, uint256) external view returns(uint256, uint256);
7
+ }
@@ -0,0 +1,9 @@
1
+ //SPDX-License-Identifier: Unlicense
2
+ pragma solidity 0.8.26;
3
+
4
+ interface IHypervisor {
5
+ function token0() external view returns (address);
6
+ function token1() external view returns (address);
7
+ function getTotalAmounts() external view returns(uint256, uint256);
8
+ function withdraw(uint256 shares, address to, address from, uint256[4] calldata minAmounts) external;
9
+ }
@@ -0,0 +1,14 @@
1
+ //SPDX-License-Identifier: Unlicense
2
+ pragma solidity 0.8.26;
3
+
4
+ interface IUniProxy {
5
+ function deposit(
6
+ uint256 deposit0,
7
+ uint256 deposit1,
8
+ address to,
9
+ address pos,
10
+ uint256[4] memory minIn
11
+ ) external;
12
+ function getSqrtTwapX96(address, uint32) external view returns(uint160);
13
+ function clearance() external view returns(address);
14
+ }