-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathISuperformRouterPlus.sol
244 lines (203 loc) · 10.4 KB
/
ISuperformRouterPlus.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.23;
import { IBaseSuperformRouterPlus } from "./IBaseSuperformRouterPlus.sol";
import { IERC20 } from "openzeppelin-contracts/contracts/interfaces/IERC20.sol";
interface ISuperformRouterPlus is IBaseSuperformRouterPlus {
//////////////////////////////////////////////////////////////
// ERRORS //
//////////////////////////////////////////////////////////////
/// @notice thrown when an invalid rebalance from selector is provided
error INVALID_REBALANCE_FROM_SELECTOR();
/// @notice thrown when an invalid deposit selector provided
error INVALID_DEPOSIT_SELECTOR();
/// @notice thrown if the interimToken is different than expected
error REBALANCE_SINGLE_POSITIONS_DIFFERENT_TOKEN();
/// @notice thrown if the liqDstChainId is different than expected
error REBALANCE_SINGLE_POSITIONS_DIFFERENT_CHAIN();
/// @notice thrown if the amounts to redeem differ
error REBALANCE_SINGLE_POSITIONS_DIFFERENT_AMOUNT();
/// @notice thrown if the receiver address is invalid (not the router plus)
error REBALANCE_SINGLE_POSITIONS_UNEXPECTED_RECEIVER_ADDRESS();
/// @notice thrown if the interimToken is different than expected in the array
error REBALANCE_MULTI_POSITIONS_DIFFERENT_TOKEN();
/// @notice thrown if the liqDstChainId is different than expected in the array
error REBALANCE_MULTI_POSITIONS_DIFFERENT_CHAIN();
/// @notice thrown if the amounts to redeem differ
error REBALANCE_MULTI_POSITIONS_DIFFERENT_AMOUNTS();
/// @notice thrown if the receiver address is invalid (not the router plus)
error REBALANCE_MULTI_POSITIONS_UNEXPECTED_RECEIVER_ADDRESS();
/// @notice thrown if the receiver address is invalid (not the router plus)
error REBALANCE_XCHAIN_INVALID_RECEIVER_ADDRESS();
/// @notice thrown if msg.value is lower than the required fee
error INVALID_FEE();
/// @notice thrown if the amount of assets received is lower than the slippage
error ASSETS_RECEIVED_OUT_OF_SLIPPAGE();
/// @notice thrown if the slippage is invalid
error INVALID_GLOBAL_SLIPPAGE();
/// @notice thrown if the tolerance is exceeded during shares redemption
error TOLERANCE_EXCEEDED();
/// @notice thrown if the amountIn is not equal or lower than the balance available
error AMOUNT_IN_NOT_EQUAL_OR_LOWER_THAN_BALANCE();
//////////////////////////////////////////////////////////////
// EVENTS //
//////////////////////////////////////////////////////////////
/// @notice emitted when a single position rebalance is completed
/// @param receiver The address receiving the rebalanced position
/// @param id The ID of the rebalanced position
/// @param amount The amount of tokens rebalanced
event RebalanceSyncCompleted(address indexed receiver, uint256 indexed id, uint256 amount);
/// @notice emitted when multiple positions are rebalanced
/// @param receiver The address receiving the rebalanced positions
/// @param ids The IDs of the rebalanced positions
/// @param amounts The amounts of tokens rebalanced for each position
event RebalanceMultiSyncCompleted(address indexed receiver, uint256[] ids, uint256[] amounts);
/// @notice emitted when a cross-chain rebalance is initiated
/// @param receiver The address receiving the rebalanced position
/// @param routerPlusPayloadId The router plus payload Id
/// @param id The ID of the position being rebalanced
/// @param amount The amount of tokens being rebalanced
/// @param interimAsset The address of the interim asset used in the cross-chain transfer
/// @param finalizeSlippage The slippage tolerance for the finalization step
/// @param expectedAmountInterimAsset The expected amount of interim asset to be received
/// @param rebalanceToSelector The selector for the rebalance to function
event XChainRebalanceInitiated(
address indexed receiver,
uint256 indexed routerPlusPayloadId,
uint256 id,
uint256 amount,
address interimAsset,
uint256 finalizeSlippage,
uint256 expectedAmountInterimAsset,
bytes4 rebalanceToSelector
);
/// @notice emitted when multiple cross-chain rebalances are initiated
/// @param receiver The address receiving the rebalanced positions
/// @param routerPlusPayloadId The router plus payload Id
/// @param ids The IDs of the positions being rebalanced
/// @param amounts The amounts of tokens being rebalanced for each position
/// @param interimAsset The address of the interim asset used in the cross-chain transfer
/// @param finalizeSlippage The slippage tolerance for the finalization step
/// @param expectedAmountInterimAsset The expected amount of interim asset to be received
/// @param rebalanceToSelector The selector for the rebalance to function
event XChainRebalanceMultiInitiated(
address indexed receiver,
uint256 indexed routerPlusPayloadId,
uint256[] ids,
uint256[] amounts,
address interimAsset,
uint256 finalizeSlippage,
uint256 expectedAmountInterimAsset,
bytes4 rebalanceToSelector
);
/// @notice emitted when a deposit from an ERC4626 vault is completed
/// @param receiver The address receiving the deposited tokens
/// @param vault The address of the ERC4626 vault
event Deposit4626Completed(address indexed receiver, address indexed vault);
/// @notice emitted when dust is forwarded to the paymaster
/// @param token The address of the token
/// @param amount The amount of tokens forwarded
event RouterPlusDustForwardedToPaymaster(address indexed token, uint256 amount);
//////////////////////////////////////////////////////////////
// STRUCTS //
//////////////////////////////////////////////////////////////
struct RebalanceSinglePositionSyncArgs {
uint256 id;
uint256 sharesToRedeem;
uint256 expectedAmountToReceivePostRebalanceFrom;
uint256 rebalanceFromMsgValue;
uint256 rebalanceToMsgValue;
address interimAsset;
uint256 slippage;
address receiverAddressSP;
bytes callData;
bytes rebalanceToCallData;
}
struct RebalanceMultiPositionsSyncArgs {
uint256[] ids;
uint256[] sharesToRedeem;
uint256 expectedAmountToReceivePostRebalanceFrom;
uint256 rebalanceFromMsgValue;
uint256 rebalanceToMsgValue;
address interimAsset;
uint256 slippage;
address receiverAddressSP;
bytes callData;
bytes rebalanceToCallData;
}
struct RebalancePositionsSyncArgs {
Actions action;
uint256[] sharesToRedeem;
uint256 expectedAmountToReceivePostRebalanceFrom;
address interimAsset;
uint256 slippage;
uint256 rebalanceFromMsgValue;
uint256 rebalanceToMsgValue;
address receiverAddressSP;
uint256 balanceBefore;
}
struct InitiateXChainRebalanceArgs {
uint256 id;
uint256 sharesToRedeem;
address receiverAddressSP;
address interimAsset;
uint256 finalizeSlippage;
uint256 expectedAmountInterimAsset;
bytes4 rebalanceToSelector;
bytes callData;
uint8[][] rebalanceToAmbIds;
uint64[] rebalanceToDstChainIds;
bytes rebalanceToSfData;
}
struct InitiateXChainRebalanceMultiArgs {
uint256[] ids;
uint256[] sharesToRedeem;
address receiverAddressSP;
address interimAsset;
uint256 finalizeSlippage;
uint256 expectedAmountInterimAsset;
bytes4 rebalanceToSelector;
bytes callData;
uint8[][] rebalanceToAmbIds;
uint64[] rebalanceToDstChainIds;
bytes rebalanceToSfData;
}
struct Deposit4626Args {
uint256 amount;
uint256 expectedOutputAmount;
uint256 maxSlippage;
address receiverAddressSP;
bytes depositCallData;
}
//////////////////////////////////////////////////////////////
// EXTERNAL WRITE FUNCTIONS //
//////////////////////////////////////////////////////////////
/// @notice rebalances a single SuperPosition synchronously
/// @notice interim asset and receiverAddressSP must be set. In non smart contract wallet rebalances,
/// receiverAddressSP is only used for refunds
/// @param args The arguments for rebalancing single positions
function rebalanceSinglePosition(RebalanceSinglePositionSyncArgs calldata args) external payable;
/// @notice rebalances multiple SuperPositions synchronously
/// @notice interim asset and receiverAddressSP must be set. In non smart contract wallet rebalances,
/// receiverAddressSP is only used for refunds
/// @notice receiverAddressSP of rebalanceCallData must be the address of the router plus for smart wallets
/// @notice for normal deposits receiverAddressSP is the users' specified receiverAddressSP
/// @param args The arguments for rebalancing multiple positions
function rebalanceMultiPositions(RebalanceMultiPositionsSyncArgs calldata args) external payable;
/// @notice initiates the rebalance process for a position on a different chain
/// @param args The arguments for initiating cross-chain rebalance for single positions
function startCrossChainRebalance(InitiateXChainRebalanceArgs calldata args) external payable;
/// @notice initiates the rebalance process for multiple positions on different chains
/// @param args The arguments for initiating cross-chain rebalance for multiple positions
function startCrossChainRebalanceMulti(InitiateXChainRebalanceMultiArgs memory args) external payable;
/// @notice deposits ERC4626 vault shares into superform
/// @param vaults_ The ERC4626 vaults to redeem from
/// @param args Rest of the arguments to deposit 4626
function deposit4626(address[] calldata vaults_, Deposit4626Args[] calldata args) external payable;
/// @dev Forwards dust to Paymaster
/// @param token_ the token to forward
function forwardDustToPaymaster(address token_) external;
/// @dev only callable by Emergency Admin
/// @notice sets the global slippage for all rebalances
/// @param slippage_ The slippage tolerance for same chain rebalances
function setGlobalSlippage(uint256 slippage_) external;
}