-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathIBranchPort.sol
224 lines (191 loc) · 8.75 KB
/
IBranchPort.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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @title Branch Port - Omnichain Token Management Contract
* @author MaiaDAO
* @notice Ulyses `Port` implementation for Branch Chain deployment. This contract
* is used to manage the deposit and withdrawal of underlying assets from
* the Branch Chain in response to Branch Bridge Agents' requests.
* Manages Bridge Agents and their factories as well as the chain's strategies and
* their tokens.
*/
interface IBranchPort {
/*///////////////////////////////////////////////////////////////
VIEW FUNCTIONS
//////////////////////////////////////////////////////////////*/
/**
* @notice Returns true if the address is a Bridge Agent.
* @param _bridgeAgent Bridge Agent address.
* @return bool.
*/
function isBridgeAgent(address _bridgeAgent) external view returns (bool);
/**
* @notice Returns true if the address is a Strategy Token.
* @param _token token address.
* @return bool.
*/
function isStrategyToken(address _token) external view returns (bool);
/**
* @notice Returns true if the address is a Port Strategy.
* @param _strategy strategy address.
* @param _token token address.
* @return bool.
*/
function isPortStrategy(address _strategy, address _token) external view returns (bool);
/**
* @notice Returns true if the address is a Bridge Agent Factory.
* @param _bridgeAgentFactory Bridge Agent Factory address.
* @return bool.
*/
function isBridgeAgentFactory(address _bridgeAgentFactory) external view returns (bool);
/*///////////////////////////////////////////////////////////////
PORT STRATEGY MANAGEMENT
//////////////////////////////////////////////////////////////*/
/**
* @notice Allows active Port Strategy addresses to withdraw assets.
* @param _token token address.
* @param _amount amount of tokens.
*/
function manage(address _token, uint256 _amount) external;
/**
* @notice allow approved address to repay borrowed reserves with reserves
* @param _amount uint
* @param _token address
*/
function replenishReserves(address _strategy, address _token, uint256 _amount) external;
/*///////////////////////////////////////////////////////////////
hTOKEN MANAGEMENT
//////////////////////////////////////////////////////////////*/
/**
* @notice Function to withdraw underlying / native token amount into Port in exchange for Local hToken.
* @param _recipient hToken receiver.
* @param _underlyingAddress underlying / native token address.
* @param _amount amount of tokens.
*
*/
function withdraw(address _recipient, address _underlyingAddress, uint256 _amount) external;
/**
* @notice Setter function to increase local hToken supply.
* @param _recipient hToken receiver.
* @param _localAddress token address.
* @param _amount amount of tokens.
*
*/
function bridgeIn(address _recipient, address _localAddress, uint256 _amount) external;
/**
* @notice Setter function to increase local hToken supply.
* @param _recipient hToken receiver.
* @param _localAddresses token addresses.
* @param _amounts amount of tokens.
*
*/
function bridgeInMultiple(address _recipient, address[] memory _localAddresses, uint256[] memory _amounts)
external;
/**
* @notice Setter function to decrease local hToken supply.
* @param _localAddress token address.
* @param _amount amount of tokens.
*
*/
function bridgeOut(
address _depositor,
address _localAddress,
address _underlyingAddress,
uint256 _amount,
uint256 _deposit
) external;
/**
* @notice Setter function to decrease local hToken supply.
* @param _depositor user to deduct balance from.
* @param _localAddresses local token addresses.
* @param _underlyingAddresses local token address.
* @param _amounts amount of local tokens.
* @param _deposits amount of underlying tokens.
*
*/
function bridgeOutMultiple(
address _depositor,
address[] memory _localAddresses,
address[] memory _underlyingAddresses,
uint256[] memory _amounts,
uint256[] memory _deposits
) external;
/*///////////////////////////////////////////////////////////////
ADMIN FUNCTIONS
//////////////////////////////////////////////////////////////*/
/**
* @notice Adds a new bridge agent address to the branch port.
* @param _bridgeAgent address of the bridge agent to add to the Port
*/
function addBridgeAgent(address _bridgeAgent) external;
/**
* @notice Sets the core router address for the branch port.
* @param _newCoreRouter address of the new core router
*/
function setCoreRouter(address _newCoreRouter) external;
/**
* @notice Adds a new bridge agent factory address to the branch port.
* @param _bridgeAgentFactory address of the bridge agent factory to add to the Port
*/
function addBridgeAgentFactory(address _bridgeAgentFactory) external;
/**
* @notice Reverts the toggle on the given bridge agent factory. If it's active, it will de-activate it and vice-versa.
* @param _newBridgeAgentFactory address of the bridge agent factory to add to the Port
*/
function toggleBridgeAgentFactory(address _newBridgeAgentFactory) external;
/**
* @notice Reverts thfe toggle on the given bridge agent If it's active, it will de-activate it and vice-versa.
* @param _bridgeAgent address of the bridge agent to add to the Port
*/
function toggleBridgeAgent(address _bridgeAgent) external;
/**
* @notice Adds a new strategy token.
* @param _token address of the token to add to the Strategy Tokens
*/
function addStrategyToken(address _token, uint256 _minimumReservesRatio) external;
/**
* @notice Reverts the toggle on the given strategy token. If it's active, it will de-activate it and vice-versa.
* @param _token address of the token to add to the Strategy Tokens
*/
function toggleStrategyToken(address _token) external;
/**
* @notice Adds a new Port strategy to the given port
* @param _portStrategy address of the bridge agent factory to add to the Port
*/
function addPortStrategy(address _portStrategy, address _token, uint256 _dailyManagementLimit) external;
/**
* @notice Reverts the toggle on the given port strategy. If it's active, it will de-activate it and vice-versa.
* @param _portStrategy address of the bridge agent factory to add to the Port
*/
function togglePortStrategy(address _portStrategy, address _token) external;
/**
* @notice Updates the daily management limit for the given port strategy.
* @param _portStrategy address of the bridge agent factory to add to the Port
* @param _token address of the token to update the limit for
* @param _dailyManagementLimit new daily management limit
*/
function updatePortStrategy(address _portStrategy, address _token, uint256 _dailyManagementLimit) external;
/*///////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
event DebtCreated(address indexed _strategy, address indexed _token, uint256 _amount);
event DebtRepaid(address indexed _strategy, address indexed _token, uint256 _amount);
event StrategyTokenAdded(address indexed _token, uint256 _minimumReservesRatio);
event StrategyTokenToggled(address indexed _token);
event PortStrategyAdded(address indexed _portStrategy, address indexed _token, uint256 _dailyManagementLimit);
event PortStrategyToggled(address indexed _portStrategy, address indexed _token);
event PortStrategyUpdated(address indexed _portStrategy, address indexed _token, uint256 _dailyManagementLimit);
event BridgeAgentFactoryAdded(address indexed _bridgeAgentFactory);
event BridgeAgentFactoryToggled(address indexed _bridgeAgentFactory);
event BridgeAgentToggled(address indexed _bridgeAgent);
/*///////////////////////////////////////////////////////////////
ERRORS
//////////////////////////////////////////////////////////////*/
error InvalidMinimumReservesRatio();
error InsufficientReserves();
error UnrecognizedCore();
error UnrecognizedBridgeAgent();
error UnrecognizedBridgeAgentFactory();
error UnrecognizedPortStrategy();
error UnrecognizedStrategyToken();
}