-
Notifications
You must be signed in to change notification settings - Fork 2
/
IRareStakingRegistry.sol
254 lines (197 loc) · 11.3 KB
/
IRareStakingRegistry.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
245
246
247
248
249
250
251
252
253
254
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @author koloz, charlescrain
/// @title IRareStakingRegistry
/// @notice The Staking Registry interface containing all functions, events, etc.
interface IRareStakingRegistry {
/*//////////////////////////////////////////////////////////////////////////
Structs
//////////////////////////////////////////////////////////////////////////*/
/// @notice A struct holding the information about the target's staking contract.
/// @dev Target being staked on is omitted as it's the key in the mapping used.
struct Info {
string name;
string symbol;
address stakingAddress;
address rewardSwapAddress;
}
/*//////////////////////////////////////////////////////////////////////////
Events
//////////////////////////////////////////////////////////////////////////*/
/// @notice Emitted via {setStakeePercentage} when the stakee update's their percentage.
event StakeePercentageUpdated(address indexed _user, uint256 _percentage);
/// @notice Emitted via {setClaimerPercentage} when the stakee update's their percentage.
event ClaimerPercentageUpdated(address indexed _user, uint256 _percentage);
/// @notice Emitted via {setDefaultPayee} when the defaultPayee is updated.
event DefaultPayeeUpdated(address _payee);
/// @notice Emitted via {setDeflationaryPercentage} when the deflationaryPercentage is updated.
event DeflationaryPercentageUpdated(uint256 _percentage);
/// @notice Emitted via {setDiscountPercentage} when the discountedPercent is updated.
event DiscountPercentageUpdated(uint256 _percentage);
/// @notice Emitted via {setPeriodLength} when the periodLength is updated.
event PeriodLengthUpdated(uint256 _periodLength);
/// @notice Emitted via {setReverseRegistrar} when the ENS reverse registrar is updated.
event ReverseRegistrarUpdated(address _percentage);
/// @notice Emitted via {setResolver} when the ENS resolver is updated.
event ResolverUpdated(address _resolver);
/// @notice Emitted via {setSwapPool} when a new swap pool has been set.
event SetSwapPool(address _uniswapPool, address _token);
/*//////////////////////////////////////////////////////////////////////////
Custom Errors
//////////////////////////////////////////////////////////////////////////*/
/// @notice Emitted when guarded functions are called by users without the necessary permissions.
error Unauthorized();
/// @notice Emitted via {setSwapPool} if the pool doesn't match the token and pairs with WETH.
error InvalidPool();
/// @notice Emitted via {setStakingAddress} if the user already has a staking address.
error StakingContractAlreadyExists();
/// @notice Emitted when Zero address provided where it is not allowed.
error ZeroAddressUnsupported();
/// @notice Error emitted in {transferRareTo} when a user performs an action that requires moving $RARE but has not made enough allowance for the registry.
error InsufficientRareAllowance();
/// @notice Emitted when a percentage is beyond the specified limit.
error PercentageBeyondLimit();
/// @notice Emitted when a Period Length is beyond the specified limit.
error PeriodLengthBeyondLimit();
/*//////////////////////////////////////////////////////////////////////////
External Write Functions
//////////////////////////////////////////////////////////////////////////*/
/// @notice Increase amount staked when a user stakes.
/// @param _staker The user who is staking.
/// @param _stakedOn The user who is being staked on.
/// @param _amount The amount of $RARE that has been staked.
function increaseAmountStaked(
address _staker,
address _stakedOn,
uint256 _amount
) external;
/// @notice Decrease the amount staked when a user unstakes.
/// @param _staker The user who is unstaking.
/// @param _stakedOn The user who was being staked on.
/// @param _amount The amount of $RARE that has been unstaked.
function decreaseAmountStaked(
address _staker,
address _stakedOn,
uint256 _amount
) external;
/// @notice Set staking addresses for a target.
/// @param _user Address of the target whose staking address is being set.
/// @param _stakingAddress Address of the staking pool contract.
/// @param _rewardSwapAddress Address of the reward swap contract.
function setStakingAddresses(
address _user,
address _stakingAddress,
address _rewardSwapAddress
) external;
/// @notice Set the default payee.
/// @param _payee Address of the account to be the new default payee.
function setDefaultPayee(address _payee) external;
/// @notice Set the reward swap discount percentage.
/// @param _percentage The new discount percentage.
function setDiscountPercentage(uint256 _percentage) external;
/// @notice Set the unstake deflationary percentage.
/// @param _percentage The new deflactionary percentage.
function setDeflationaryPercentage(uint256 _percentage) external;
/// @notice Set the round period length time.
/// @param _periodLength The new period start.
function setPeriodLength(uint256 _periodLength) external;
/// @notice Set the ENS reverse registrar address.
/// @param _reverseRegistrar The new period start.
function setReverseRegistrar(address _reverseRegistrar) external;
/// @notice Set the ENS resolver address.
/// @param _resolver The new period start.
function setResolver(address _resolver) external;
/// @notice Set the uniswap pool address for the given ERC20 token.
/// @param _uniswapPool Address of uniswap pool.
/// @param _token Address of ERC20 contract.
function setSwapPool(address _uniswapPool, address _token) external;
/// @notice Set stakee percentage.
/// @param _stakeePercentage The new stakee percentage.
function setStakeePercentage(uint256 _stakeePercentage) external;
/// @notice Set claimer percentage.
/// @param _claimerPercentage The new stakee percentage.
function setClaimerPercentage(uint256 _claimerPercentage) external;
/// @notice Pools to transfer $RARE tokens, usually into pools. This is so users only need to approve the registry when staking or performing reward swaps.
/// @param _from Address to transfer the tokens from.
/// @param _to Address to transfer the tokens to.
/// @param _amount uint256 amount to transfer.
function transferRareTo(
address _from,
address _to,
uint256 _amount
) external;
/*//////////////////////////////////////////////////////////////////////////
External Read Functions
//////////////////////////////////////////////////////////////////////////*/
/// @notice Get the address for sending rewards if there are no stakers.
/// @return address to send rewards to.
function getDefaultPayee() external view returns (address);
/// @notice Get the swap pool address for the ERC20 token.
/// @return address of the swap pool associated with the token.
function getSwapPool(address _token) external view returns (address);
/// @notice Retrieve the address of $RARE.
/// @return address Address of $RARE (the staking token to be used).
function getRareAddress() external view returns (address);
/// @notice Retrieve the address of Wrapped Ethereum.
/// @return address Address of Wrapped Ethereum.
function getWethAddress() external view returns (address);
/// @notice Get reward swap discount percentage.
/// @return uint256 discount percentage.
function getDiscountPercentage() external view returns (uint256);
/// @notice Get the unstake deflationary percentage.
/// @return uint256 deflationary percentage.
function getDeflationaryPercentage() external view returns (uint256);
/// @notice Get the stakee percentage.
/// @param _user Address of the user being staked on.
/// @return uint256 stakee percentage.
function getStakeePercentage(address _user) external view returns (uint256);
/// @notice Get the claimer percentage.
/// @param _user Address of the user reawards are being claimed for.
/// @return uint256 claimer percentage.
function getClaimerPercentage(address _user) external view returns (uint256);
/// @notice Get the round period length.
/// @return uint256 period length.
function getPeriodLength() external view returns (uint256);
/// @notice Retrieves the staking info for a given user.
/// @param _user Address of user being queried.
/// @return Info struct containing name, symbol, and staking address.
function getStakingInfoForUser(address _user) external view returns (Info memory);
/// @notice Retrieves the total amount of rare staked by a given user.
/// @param _user Address of the user staking.
/// @return uint256 Amount of rare the user is staking.
function getTotalAmountStakedByUser(address _user) external view returns (uint256);
/// @notice Retrieves the total amount of rare being staked on a given user.
/// @param _user Address of the user being staked on.
/// @return uint256 Amount of rare being staked on the user.
function getTotalAmountStakedOnUser(address _user) external view returns (uint256);
/// @notice Retrieves a list of all the ERC20 staking contracts.
/// @return list of contracts users can use to stake.
function getAllStakingContracts() external view returns (address[] memory);
/// @notice Retrieves a list of all the users participating in staking.
/// @return list of addresses of all the users who are currently staking.
function getAllStakers() external view returns (address[] memory);
/// @notice Retrieves a list of all the users being staked on.
/// @return list of addresses of all the users who are being staked on.
function getAllStakedOn() external view returns (address[] memory);
/// @notice Query the users for the following staking addresseses.
/// @param _stakingAddrs Addresses of staking contracts being queried.
function getUsersForStakingAddresses(address[] calldata _stakingAddrs) external view returns (address[] memory);
/// @notice Bytes32 representation of the role used for setting the staking address of a user.
/// @return bytes32 value of the staking info setter role.
function STAKING_INFO_SETTER_ROLE() external view returns (bytes32);
/// @notice Bytes32 representation of the admin role for granting the ability to set amount staked for a single user/total amount staked on a user.
/// @return bytes32 value of the staking stat setter admin role.
function STAKING_STAT_SETTER_ADMIN_ROLE() external view returns (bytes32);
/// @notice Bytes32 representation of the role used for updating the amount being staked on a user/amount a user is staking globally.
/// @return bytes32 value of the stat setter role.
function STAKING_STAT_SETTER_ROLE() external view returns (bytes32);
/// @notice Bytes32 representation of the role used for period length, deflationary percentages, and the default payee.
/// @return bytes32 value of the staking config setter role.
function STAKING_CONFIG_SETTER_ROLE() external view returns (bytes32);
/// @notice Bytes32 representation of the role used for updating the ENS resolvers.
/// @return bytes32 value of the ens setter role.
function ENS_SETTER_ROLE() external view returns (bytes32);
/// @notice Bytes32 representation of the role used for updating uniswap pools.
/// @return bytes32 value of the swap pool setter role.
function SWAP_POOL_SETTER_ROLE() external view returns (bytes32);
}