@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,253 @@
|
|
1
|
+
// SPDX-License-Identifier: BUSL-1.1
|
2
|
+
pragma solidity 0.8.26;
|
3
|
+
|
4
|
+
library EventUtils {
|
5
|
+
struct EmitPositionDecreaseParams {
|
6
|
+
bytes32 key;
|
7
|
+
address account;
|
8
|
+
address market;
|
9
|
+
address collateralToken;
|
10
|
+
bool isLong;
|
11
|
+
}
|
12
|
+
|
13
|
+
struct EventLogData {
|
14
|
+
AddressItems addressItems;
|
15
|
+
UintItems uintItems;
|
16
|
+
IntItems intItems;
|
17
|
+
BoolItems boolItems;
|
18
|
+
Bytes32Items bytes32Items;
|
19
|
+
BytesItems bytesItems;
|
20
|
+
StringItems stringItems;
|
21
|
+
}
|
22
|
+
|
23
|
+
struct AddressItems {
|
24
|
+
AddressKeyValue[] items;
|
25
|
+
AddressArrayKeyValue[] arrayItems;
|
26
|
+
}
|
27
|
+
|
28
|
+
struct UintItems {
|
29
|
+
UintKeyValue[] items;
|
30
|
+
UintArrayKeyValue[] arrayItems;
|
31
|
+
}
|
32
|
+
|
33
|
+
struct IntItems {
|
34
|
+
IntKeyValue[] items;
|
35
|
+
IntArrayKeyValue[] arrayItems;
|
36
|
+
}
|
37
|
+
|
38
|
+
struct BoolItems {
|
39
|
+
BoolKeyValue[] items;
|
40
|
+
BoolArrayKeyValue[] arrayItems;
|
41
|
+
}
|
42
|
+
|
43
|
+
struct Bytes32Items {
|
44
|
+
Bytes32KeyValue[] items;
|
45
|
+
Bytes32ArrayKeyValue[] arrayItems;
|
46
|
+
}
|
47
|
+
|
48
|
+
struct BytesItems {
|
49
|
+
BytesKeyValue[] items;
|
50
|
+
BytesArrayKeyValue[] arrayItems;
|
51
|
+
}
|
52
|
+
|
53
|
+
struct StringItems {
|
54
|
+
StringKeyValue[] items;
|
55
|
+
StringArrayKeyValue[] arrayItems;
|
56
|
+
}
|
57
|
+
|
58
|
+
struct AddressKeyValue {
|
59
|
+
string key;
|
60
|
+
address value;
|
61
|
+
}
|
62
|
+
|
63
|
+
struct AddressArrayKeyValue {
|
64
|
+
string key;
|
65
|
+
address[] value;
|
66
|
+
}
|
67
|
+
|
68
|
+
struct UintKeyValue {
|
69
|
+
string key;
|
70
|
+
uint256 value;
|
71
|
+
}
|
72
|
+
|
73
|
+
struct UintArrayKeyValue {
|
74
|
+
string key;
|
75
|
+
uint256[] value;
|
76
|
+
}
|
77
|
+
|
78
|
+
struct IntKeyValue {
|
79
|
+
string key;
|
80
|
+
int256 value;
|
81
|
+
}
|
82
|
+
|
83
|
+
struct IntArrayKeyValue {
|
84
|
+
string key;
|
85
|
+
int256[] value;
|
86
|
+
}
|
87
|
+
|
88
|
+
struct BoolKeyValue {
|
89
|
+
string key;
|
90
|
+
bool value;
|
91
|
+
}
|
92
|
+
|
93
|
+
struct BoolArrayKeyValue {
|
94
|
+
string key;
|
95
|
+
bool[] value;
|
96
|
+
}
|
97
|
+
|
98
|
+
struct Bytes32KeyValue {
|
99
|
+
string key;
|
100
|
+
bytes32 value;
|
101
|
+
}
|
102
|
+
|
103
|
+
struct Bytes32ArrayKeyValue {
|
104
|
+
string key;
|
105
|
+
bytes32[] value;
|
106
|
+
}
|
107
|
+
|
108
|
+
struct BytesKeyValue {
|
109
|
+
string key;
|
110
|
+
bytes value;
|
111
|
+
}
|
112
|
+
|
113
|
+
struct BytesArrayKeyValue {
|
114
|
+
string key;
|
115
|
+
bytes[] value;
|
116
|
+
}
|
117
|
+
|
118
|
+
struct StringKeyValue {
|
119
|
+
string key;
|
120
|
+
string value;
|
121
|
+
}
|
122
|
+
|
123
|
+
struct StringArrayKeyValue {
|
124
|
+
string key;
|
125
|
+
string[] value;
|
126
|
+
}
|
127
|
+
|
128
|
+
function initItems(AddressItems memory items, uint256 size) internal pure {
|
129
|
+
items.items = new EventUtils.AddressKeyValue[](size);
|
130
|
+
}
|
131
|
+
|
132
|
+
function initArrayItems(AddressItems memory items, uint256 size) internal pure {
|
133
|
+
items.arrayItems = new EventUtils.AddressArrayKeyValue[](size);
|
134
|
+
}
|
135
|
+
|
136
|
+
function setItem(AddressItems memory items, uint256 index, string memory key, address value) internal pure {
|
137
|
+
items.items[index].key = key;
|
138
|
+
items.items[index].value = value;
|
139
|
+
}
|
140
|
+
|
141
|
+
function setItem(AddressItems memory items, uint256 index, string memory key, address[] memory value) internal pure {
|
142
|
+
items.arrayItems[index].key = key;
|
143
|
+
items.arrayItems[index].value = value;
|
144
|
+
}
|
145
|
+
|
146
|
+
function initItems(UintItems memory items, uint256 size) internal pure {
|
147
|
+
items.items = new EventUtils.UintKeyValue[](size);
|
148
|
+
}
|
149
|
+
|
150
|
+
function initArrayItems(UintItems memory items, uint256 size) internal pure {
|
151
|
+
items.arrayItems = new EventUtils.UintArrayKeyValue[](size);
|
152
|
+
}
|
153
|
+
|
154
|
+
function setItem(UintItems memory items, uint256 index, string memory key, uint256 value) internal pure {
|
155
|
+
items.items[index].key = key;
|
156
|
+
items.items[index].value = value;
|
157
|
+
}
|
158
|
+
|
159
|
+
function setItem(UintItems memory items, uint256 index, string memory key, uint256[] memory value) internal pure {
|
160
|
+
items.arrayItems[index].key = key;
|
161
|
+
items.arrayItems[index].value = value;
|
162
|
+
}
|
163
|
+
|
164
|
+
function initItems(IntItems memory items, uint256 size) internal pure {
|
165
|
+
items.items = new EventUtils.IntKeyValue[](size);
|
166
|
+
}
|
167
|
+
|
168
|
+
function initArrayItems(IntItems memory items, uint256 size) internal pure {
|
169
|
+
items.arrayItems = new EventUtils.IntArrayKeyValue[](size);
|
170
|
+
}
|
171
|
+
|
172
|
+
function setItem(IntItems memory items, uint256 index, string memory key, int256 value) internal pure {
|
173
|
+
items.items[index].key = key;
|
174
|
+
items.items[index].value = value;
|
175
|
+
}
|
176
|
+
|
177
|
+
function setItem(IntItems memory items, uint256 index, string memory key, int256[] memory value) internal pure {
|
178
|
+
items.arrayItems[index].key = key;
|
179
|
+
items.arrayItems[index].value = value;
|
180
|
+
}
|
181
|
+
|
182
|
+
function initItems(BoolItems memory items, uint256 size) internal pure {
|
183
|
+
items.items = new EventUtils.BoolKeyValue[](size);
|
184
|
+
}
|
185
|
+
|
186
|
+
function initArrayItems(BoolItems memory items, uint256 size) internal pure {
|
187
|
+
items.arrayItems = new EventUtils.BoolArrayKeyValue[](size);
|
188
|
+
}
|
189
|
+
|
190
|
+
function setItem(BoolItems memory items, uint256 index, string memory key, bool value) internal pure {
|
191
|
+
items.items[index].key = key;
|
192
|
+
items.items[index].value = value;
|
193
|
+
}
|
194
|
+
|
195
|
+
function setItem(BoolItems memory items, uint256 index, string memory key, bool[] memory value) internal pure {
|
196
|
+
items.arrayItems[index].key = key;
|
197
|
+
items.arrayItems[index].value = value;
|
198
|
+
}
|
199
|
+
|
200
|
+
function initItems(Bytes32Items memory items, uint256 size) internal pure {
|
201
|
+
items.items = new EventUtils.Bytes32KeyValue[](size);
|
202
|
+
}
|
203
|
+
|
204
|
+
function initArrayItems(Bytes32Items memory items, uint256 size) internal pure {
|
205
|
+
items.arrayItems = new EventUtils.Bytes32ArrayKeyValue[](size);
|
206
|
+
}
|
207
|
+
|
208
|
+
function setItem(Bytes32Items memory items, uint256 index, string memory key, bytes32 value) internal pure {
|
209
|
+
items.items[index].key = key;
|
210
|
+
items.items[index].value = value;
|
211
|
+
}
|
212
|
+
|
213
|
+
function setItem(Bytes32Items memory items, uint256 index, string memory key, bytes32[] memory value) internal pure {
|
214
|
+
items.arrayItems[index].key = key;
|
215
|
+
items.arrayItems[index].value = value;
|
216
|
+
}
|
217
|
+
|
218
|
+
function initItems(BytesItems memory items, uint256 size) internal pure {
|
219
|
+
items.items = new EventUtils.BytesKeyValue[](size);
|
220
|
+
}
|
221
|
+
|
222
|
+
function initArrayItems(BytesItems memory items, uint256 size) internal pure {
|
223
|
+
items.arrayItems = new EventUtils.BytesArrayKeyValue[](size);
|
224
|
+
}
|
225
|
+
|
226
|
+
function setItem(BytesItems memory items, uint256 index, string memory key, bytes memory value) internal pure {
|
227
|
+
items.items[index].key = key;
|
228
|
+
items.items[index].value = value;
|
229
|
+
}
|
230
|
+
|
231
|
+
function setItem(BytesItems memory items, uint256 index, string memory key, bytes[] memory value) internal pure {
|
232
|
+
items.arrayItems[index].key = key;
|
233
|
+
items.arrayItems[index].value = value;
|
234
|
+
}
|
235
|
+
|
236
|
+
function initItems(StringItems memory items, uint256 size) internal pure {
|
237
|
+
items.items = new EventUtils.StringKeyValue[](size);
|
238
|
+
}
|
239
|
+
|
240
|
+
function initArrayItems(StringItems memory items, uint256 size) internal pure {
|
241
|
+
items.arrayItems = new EventUtils.StringArrayKeyValue[](size);
|
242
|
+
}
|
243
|
+
|
244
|
+
function setItem(StringItems memory items, uint256 index, string memory key, string memory value) internal pure {
|
245
|
+
items.items[index].key = key;
|
246
|
+
items.items[index].value = value;
|
247
|
+
}
|
248
|
+
|
249
|
+
function setItem(StringItems memory items, uint256 index, string memory key, string[] memory value) internal pure {
|
250
|
+
items.arrayItems[index].key = key;
|
251
|
+
items.arrayItems[index].value = value;
|
252
|
+
}
|
253
|
+
}
|
@@ -0,0 +1,119 @@
|
|
1
|
+
// SPDX-License-Identifier: BUSL-1.1
|
2
|
+
pragma solidity 0.8.26;
|
3
|
+
|
4
|
+
import "./EventUtils.sol";
|
5
|
+
|
6
|
+
interface ICallbackReceiver {
|
7
|
+
// @dev there is a limit on the number of fields a struct can have when being passed
|
8
|
+
// or returned as a memory variable which can cause "Stack too deep" errors
|
9
|
+
// use sub-structs to avoid this issue
|
10
|
+
// @param addresses address values
|
11
|
+
// @param numbers number values
|
12
|
+
// @param flags boolean values
|
13
|
+
struct DepositProps {
|
14
|
+
DepositAddresses addresses;
|
15
|
+
DepositNumbers numbers;
|
16
|
+
Flags flags;
|
17
|
+
}
|
18
|
+
|
19
|
+
// @dev there is a limit on the number of fields a struct can have when being passed
|
20
|
+
// or returned as a memory variable which can cause "Stack too deep" errors
|
21
|
+
// use sub-structs to avoid this issue
|
22
|
+
// @param addresses address values
|
23
|
+
// @param numbers number values
|
24
|
+
// @param flags boolean values
|
25
|
+
struct WithdrawalProps {
|
26
|
+
WithdrawalAddresses addresses;
|
27
|
+
WithdrawalNumbers numbers;
|
28
|
+
Flags flags;
|
29
|
+
}
|
30
|
+
|
31
|
+
// @param account the account depositing liquidity
|
32
|
+
// @param receiver the address to send the liquidity tokens to
|
33
|
+
// @param callbackContract the callback contract
|
34
|
+
// @param uiFeeReceiver the ui fee receiver
|
35
|
+
// @param market the market to deposit to
|
36
|
+
struct DepositAddresses {
|
37
|
+
address account;
|
38
|
+
address receiver;
|
39
|
+
address callbackContract;
|
40
|
+
address uiFeeReceiver;
|
41
|
+
address market;
|
42
|
+
address initialLongToken;
|
43
|
+
address initialShortToken;
|
44
|
+
address[] longTokenSwapPath;
|
45
|
+
address[] shortTokenSwapPath;
|
46
|
+
}
|
47
|
+
|
48
|
+
// @param initialLongTokenAmount the amount of long tokens to deposit
|
49
|
+
// @param initialShortTokenAmount the amount of short tokens to deposit
|
50
|
+
// @param minMarketTokens the minimum acceptable number of liquidity tokens
|
51
|
+
// @param updatedAtBlock the block that the deposit was last updated at
|
52
|
+
// sending funds back to the user in case the deposit gets cancelled
|
53
|
+
// @param executionFee the execution fee for keepers
|
54
|
+
// @param callbackGasLimit the gas limit for the callbackContract
|
55
|
+
struct DepositNumbers {
|
56
|
+
uint256 initialLongTokenAmount;
|
57
|
+
uint256 initialShortTokenAmount;
|
58
|
+
uint256 minMarketTokens;
|
59
|
+
uint256 updatedAtBlock;
|
60
|
+
uint256 updatedAtTime;
|
61
|
+
uint256 executionFee;
|
62
|
+
uint256 callbackGasLimit;
|
63
|
+
}
|
64
|
+
|
65
|
+
// @param account The account to withdraw for.
|
66
|
+
// @param receiver The address that will receive the withdrawn tokens.
|
67
|
+
// @param callbackContract The contract that will be called back.
|
68
|
+
// @param uiFeeReceiver The ui fee receiver.
|
69
|
+
// @param market The market on which the withdrawal will be executed.
|
70
|
+
struct WithdrawalAddresses {
|
71
|
+
address account;
|
72
|
+
address receiver;
|
73
|
+
address callbackContract;
|
74
|
+
address uiFeeReceiver;
|
75
|
+
address market;
|
76
|
+
address[] longTokenSwapPath;
|
77
|
+
address[] shortTokenSwapPath;
|
78
|
+
}
|
79
|
+
|
80
|
+
// @param marketTokenAmount The amount of market tokens that will be withdrawn.
|
81
|
+
// @param minLongTokenAmount The minimum amount of long tokens that must be withdrawn.
|
82
|
+
// @param minShortTokenAmount The minimum amount of short tokens that must be withdrawn.
|
83
|
+
// @param updatedAtBlock The block at which the withdrawal was last updated.
|
84
|
+
// @param executionFee The execution fee for the withdrawal.
|
85
|
+
// @param callbackGasLimit The gas limit for calling the callback contract.
|
86
|
+
struct WithdrawalNumbers {
|
87
|
+
uint256 marketTokenAmount;
|
88
|
+
uint256 minLongTokenAmount;
|
89
|
+
uint256 minShortTokenAmount;
|
90
|
+
uint256 updatedAtBlock;
|
91
|
+
uint256 updatedAtTime;
|
92
|
+
uint256 executionFee;
|
93
|
+
uint256 callbackGasLimit;
|
94
|
+
}
|
95
|
+
|
96
|
+
// @param shouldUnwrapNativeToken whether to unwrap the native token when
|
97
|
+
struct Flags {
|
98
|
+
bool shouldUnwrapNativeToken;
|
99
|
+
}
|
100
|
+
// @dev called after a deposit execution
|
101
|
+
// @param key the key of the deposit
|
102
|
+
// @param deposit the deposit that was executed
|
103
|
+
function afterDepositExecution(bytes32 key, DepositProps memory deposit, EventUtils.EventLogData memory eventData) external;
|
104
|
+
|
105
|
+
// @dev called after a deposit cancellation
|
106
|
+
// @param key the key of the deposit
|
107
|
+
// @param deposit the deposit that was cancelled
|
108
|
+
function afterDepositCancellation(bytes32 key, DepositProps memory deposit, EventUtils.EventLogData memory eventData) external;
|
109
|
+
|
110
|
+
// @dev called after a withdrawal execution
|
111
|
+
// @param key the key of the withdrawal
|
112
|
+
// @param withdrawal the withdrawal that was executed
|
113
|
+
function afterWithdrawalExecution(bytes32 key, WithdrawalProps memory withdrawal, EventUtils.EventLogData memory eventData) external;
|
114
|
+
|
115
|
+
// @dev called after a withdrawal cancellation
|
116
|
+
// @param key the key of the withdrawal
|
117
|
+
// @param withdrawal the withdrawal that was cancelled
|
118
|
+
function afterWithdrawalCancellation(bytes32 key, WithdrawalProps memory withdrawal, EventUtils.EventLogData memory eventData) external;
|
119
|
+
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
// SPDX-License-Identifier: Unlicense
|
2
|
+
pragma solidity 0.8.26;
|
3
|
+
|
4
|
+
interface IExchangeRouter {
|
5
|
+
struct CreateDepositParams {
|
6
|
+
address receiver;
|
7
|
+
address callbackContract;
|
8
|
+
address uiFeeReceiver;
|
9
|
+
address market;
|
10
|
+
address initialLongToken;
|
11
|
+
address initialShortToken;
|
12
|
+
address[] longTokenSwapPath;
|
13
|
+
address[] shortTokenSwapPath;
|
14
|
+
uint256 minMarketTokens;
|
15
|
+
bool shouldUnwrapNativeToken;
|
16
|
+
uint256 executionFee;
|
17
|
+
uint256 callbackGasLimit;
|
18
|
+
}
|
19
|
+
struct CreateWithdrawalParams {
|
20
|
+
address receiver;
|
21
|
+
address callbackContract;
|
22
|
+
address uiFeeReceiver;
|
23
|
+
address market;
|
24
|
+
address[] longTokenSwapPath;
|
25
|
+
address[] shortTokenSwapPath;
|
26
|
+
uint256 minLongTokenAmount;
|
27
|
+
uint256 minShortTokenAmount;
|
28
|
+
bool shouldUnwrapNativeToken;
|
29
|
+
uint256 executionFee;
|
30
|
+
uint256 callbackGasLimit;
|
31
|
+
}
|
32
|
+
|
33
|
+
function sendWnt(address receiver, uint256 amount) external payable;
|
34
|
+
function sendTokens(address token, address receiver, uint256 amount) external payable;
|
35
|
+
function createDeposit(CreateDepositParams calldata params) external payable returns (bytes32);
|
36
|
+
function createWithdrawal(CreateWithdrawalParams calldata params) external payable returns (bytes32);
|
37
|
+
function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);
|
38
|
+
}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
2
|
+
pragma solidity 0.8.26;
|
3
|
+
|
4
|
+
interface IGMXViewer {
|
5
|
+
function getWithdrawalAmountOut(address market, uint256 amount, bool stalenessCheck) external view returns (uint256);
|
6
|
+
function getDepositAmountOut(address market, uint256 amount, bool stalenessCheck) external view returns (uint256);
|
7
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
2
|
+
pragma solidity 0.8.26;
|
3
|
+
|
4
|
+
interface IHandler {
|
5
|
+
struct SetPricesParams {
|
6
|
+
address[] tokens;
|
7
|
+
address[] providers;
|
8
|
+
bytes[] data;
|
9
|
+
}
|
10
|
+
function executeDeposit(bytes32 key, SetPricesParams calldata oracleParams) external;
|
11
|
+
function executeWithdrawal(bytes32 key, SetPricesParams calldata oracleParams) external;
|
12
|
+
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
// SPDX-License-Identifier: Unlicense
|
2
|
+
pragma solidity 0.8.26;
|
3
|
+
|
4
|
+
import "./IMarket.sol";
|
5
|
+
|
6
|
+
interface IReader {
|
7
|
+
struct PriceProps {
|
8
|
+
uint256 min;
|
9
|
+
uint256 max;
|
10
|
+
}
|
11
|
+
struct MarketProps {
|
12
|
+
address marketToken;
|
13
|
+
address indexToken;
|
14
|
+
address longToken;
|
15
|
+
address shortToken;
|
16
|
+
}
|
17
|
+
struct MarketPrices {
|
18
|
+
PriceProps indexTokenPrice;
|
19
|
+
PriceProps longTokenPrice;
|
20
|
+
PriceProps shortTokenPrice;
|
21
|
+
}
|
22
|
+
enum SwapPricingType {
|
23
|
+
TwoStep,
|
24
|
+
Shift,
|
25
|
+
Atomic
|
26
|
+
}
|
27
|
+
|
28
|
+
function getMarket(address dataStore, address key) external view returns (MarketProps memory);
|
29
|
+
|
30
|
+
function getDepositAmountOut(
|
31
|
+
address dataStore,
|
32
|
+
MarketProps memory market,
|
33
|
+
MarketPrices memory prices,
|
34
|
+
uint256 longTokenAmount,
|
35
|
+
uint256 shortTokenAmount,
|
36
|
+
address uiFeeReceiver,
|
37
|
+
SwapPricingType swapPricingType,
|
38
|
+
bool includeVirtualInventoryImpact
|
39
|
+
) external view returns (uint256);
|
40
|
+
|
41
|
+
function getWithdrawalAmountOut(
|
42
|
+
address dataStore,
|
43
|
+
MarketProps memory market,
|
44
|
+
MarketPrices memory prices,
|
45
|
+
uint256 marketTokenAmount,
|
46
|
+
address uiFeeReceiver,
|
47
|
+
SwapPricingType swapPricingType
|
48
|
+
) external view returns (uint256, uint256);
|
49
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
// SPDX-License-Identifier: BUSL-1.1
|
2
|
+
pragma solidity 0.8.26;
|
3
|
+
|
4
|
+
/// @title Errors in Ipor Fusion
|
5
|
+
library Errors {
|
6
|
+
/// @notice Error when wrong address is used
|
7
|
+
error WrongAddress();
|
8
|
+
/// @notice Error when wrong value is used
|
9
|
+
error WrongValue();
|
10
|
+
/// @notice Error when wrong decimals are used
|
11
|
+
error WrongDecimals();
|
12
|
+
/// @notice Error when wrong array length is used
|
13
|
+
error WrongArrayLength();
|
14
|
+
/// @notice Error when wrong caller is used
|
15
|
+
error WrongCaller(address caller);
|
16
|
+
/// @notice Error when wrong quote currency is used
|
17
|
+
error UnsupportedQuoteCurrencyFromOracle();
|
18
|
+
/// @notice Error when unsupported price oracle middleware is used
|
19
|
+
error UnsupportedPriceOracleMiddleware();
|
20
|
+
}
|
@@ -0,0 +1,71 @@
|
|
1
|
+
|
2
|
+
// SPDX-License-Identifier: BUSL-1.1
|
3
|
+
pragma solidity 0.8.26;
|
4
|
+
|
5
|
+
/// @title Fuses storage library responsible for managing storage fuses in the Plasma Vault
|
6
|
+
library FuseStorageLib {
|
7
|
+
/// @dev keccak256(abi.encode(uint256(keccak256("io.ipor.CfgFuses")) - 1)) & ~bytes32(uint256(0xff));
|
8
|
+
bytes32 private constant CFG_FUSES = 0x48932b860eb451ad240d4fe2b46522e5a0ac079d201fe50d4e0be078c75b5400;
|
9
|
+
|
10
|
+
/// @dev keccak256(abi.encode(uint256(keccak256("io.ipor.CfgFusesArray")) - 1)) & ~bytes32(uint256(0xff));
|
11
|
+
bytes32 private constant CFG_FUSES_ARRAY = 0xad43e358bd6e59a5a0c80f6bf25fa771408af4d80f621cdc680c8dfbf607ab00;
|
12
|
+
|
13
|
+
/// @notice This memory is designed to use with Uniswap V3 fuses
|
14
|
+
/// @dev keccak256(abi.encode(uint256(keccak256("io.ipor.UniswapV3TokenIds")) - 1)) & ~bytes32(uint256(0xff));
|
15
|
+
bytes32 private constant UNISWAP_V3_TOKEN_IDS = 0x3651659bd419f7c37743f3e14a337c9f9d1cfc4d650d91508f44d1acbe960f00;
|
16
|
+
|
17
|
+
/// @notice This memory is designed to use with Ramses V2 fuses
|
18
|
+
/// @dev keccak256(abi.encode(uint256(keccak256("io.ipor.RamsesV2TokenIds")) - 1)) & ~bytes32(uint256(0xff));
|
19
|
+
bytes32 private constant RAMSES_V2_TOKEN_IDS = 0x1a3831a406f27d4d5d820158b29ce95a1e8e840bf416921917aa388e2461b700;
|
20
|
+
|
21
|
+
/// @custom:storage-location erc7201:io.ipor.CfgFuses
|
22
|
+
struct Fuses {
|
23
|
+
/// @dev fuse address => If index = 0 - is not granted, otherwise - granted
|
24
|
+
mapping(address fuse => uint256 index) value;
|
25
|
+
}
|
26
|
+
|
27
|
+
/// @custom:storage-location erc7201:io.ipor.CfgFusesArray
|
28
|
+
struct FusesArray {
|
29
|
+
/// @dev value is a fuse address
|
30
|
+
address[] value;
|
31
|
+
}
|
32
|
+
|
33
|
+
/// @custom:storage-location erc7201:io.ipor.UniswapV3TokenIds
|
34
|
+
struct UniswapV3TokenIds {
|
35
|
+
uint256[] tokenIds;
|
36
|
+
mapping(uint256 tokenId => uint256 index) indexes;
|
37
|
+
}
|
38
|
+
|
39
|
+
/// @custom:storage-location erc7201:io.ipor.RamsesV2TokenIds
|
40
|
+
struct RamsesV2TokenIds {
|
41
|
+
uint256[] tokenIds;
|
42
|
+
mapping(uint256 tokenId => uint256 index) indexes;
|
43
|
+
}
|
44
|
+
|
45
|
+
/// @notice Gets the fuses storage pointer
|
46
|
+
function getFuses() internal pure returns (Fuses storage fuses) {
|
47
|
+
assembly {
|
48
|
+
fuses.slot := CFG_FUSES
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
/// @notice Gets the fuses array storage pointer
|
53
|
+
function getFusesArray() internal pure returns (FusesArray storage fusesArray) {
|
54
|
+
assembly {
|
55
|
+
fusesArray.slot := CFG_FUSES_ARRAY
|
56
|
+
}
|
57
|
+
}
|
58
|
+
|
59
|
+
/// @notice Gets the UniswapV3TokenIds storage pointer
|
60
|
+
function getUniswapV3TokenIds() internal pure returns (UniswapV3TokenIds storage uniswapV3TokenIds) {
|
61
|
+
assembly {
|
62
|
+
uniswapV3TokenIds.slot := UNISWAP_V3_TOKEN_IDS
|
63
|
+
}
|
64
|
+
}
|
65
|
+
/// @notice Gets the UniswapV3TokenIds storage pointer
|
66
|
+
function getRamsesV2TokenIds() internal pure returns (RamsesV2TokenIds storage ramsesV2TokenIds) {
|
67
|
+
assembly {
|
68
|
+
ramsesV2TokenIds.slot := RAMSES_V2_TOKEN_IDS
|
69
|
+
}
|
70
|
+
}
|
71
|
+
}
|