Skip to content

Commit edb7787

Browse files
committed
Commented the imported tokenregistry sol
1 parent 1c463af commit edb7787

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/bindings.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,47 +135,69 @@ pub mod contract {
135135

136136
event GHyprSet(address indexed gHypr);
137137

138+
/// Initializes the TokenRegistry with HYPR token and admin.
139+
/// Reverts InvalidAdmin if admin is zero; UnsupportedToken if hypr is zero.
138140
function initialize(address _hypr, address _admin) external;
139141

142+
/// Locks tokens or modifies an existing lock.
143+
/// Emits TokensLocked/LockExtended. Reverts on zero amount, expired lock,
144+
/// invalid amount, or invalid duration.
140145
function manageLock(uint256 _amount, uint256 _duration) external;
141146

147+
/// Returns true if the user's lock has expired.
142148
function isLockExpired(address _account) external view returns (bool);
143149

150+
/// Withdraws unlocked tokens, consolidating bindings first.
151+
/// Emits TokensBound/TokensWithdrawn. May require multiple calls if many bindings.
144152
function withdraw() external returns (bool);
145153

154+
/// Retrieves lock details for a user.
146155
function getLockDetails(address _user)
147156
external
148157
view
149158
returns (uint256 amount, uint256 endTime, uint256 remainingTime);
150159

160+
/// Retrieves registration details for a user/namehash.
151161
function getRegistrationDetails(bytes32 _namehash, address _user)
152162
external
153163
view
154164
returns (uint256 amount, uint256 endTime, uint256 remainingTime);
155165

166+
/// Transfers tokens between registrations for the caller.
167+
/// Source must be expired or default. Emits TokensBound/BindCreated/
168+
/// BindAmountIncreased/BindDurationExtended. Reverts on invalid duration,
169+
/// invalid params for default dest, expired lock, unexpired source, or zero
170+
/// amount/duration for new binds.
156171
function transferRegistration(
157172
bytes32 _srcNamehash,
158173
bytes32 _dstNamehash,
159174
uint256 _maxAmount,
160175
uint256 _duration
161176
) external;
162177

178+
/// Returns all binding namehashes for a user.
163179
function getUserBinds(address _user) external view returns (bytes32[] memory);
164180

181+
/// Calculates sublinear voting power for a balance/duration.
165182
function calculateVotingPower(uint256 _value, uint256 _lockDuration)
166183
external
167184
view
168185
returns (uint256);
169186

187+
/// Gets the multiplier for an account (or total supply if zero) at a timepoint.
170188
function getMultiplier(address _account, uint256 _timepoint)
171189
external
172190
view
173191
returns (uint256);
174192

193+
/// Gets the user's unlock timestamp.
175194
function getUserUnlockStamp(address _account) external view returns (uint256);
176195

196+
/// Gets user's unlock or delegated unlock timestamp, whichever is later.
177197
function getUserOrDelegatedUnlockStamp(address _account) external view returns (uint256);
178198

199+
/// Updates voting multipliers when delegation changes.
200+
/// Only callable by governance token; reverts otherwise.
179201
function updateDelegationMultipliers(
180202
uint256 _unlockTime,
181203
uint256 _movedVotes,
@@ -185,13 +207,16 @@ pub mod contract {
185207
uint256 _dstVotesBefore
186208
) external;
187209

210+
/// Calculates weighted unlock timestamp for locks.
188211
function calculateWeightedUnlockStamp(
189212
uint256 _remainingDuration,
190213
uint256 _currentBalance,
191214
uint256 _newLockDuration,
192215
uint256 _newLockAmount
193216
) external view returns (uint256);
194217

218+
/// Calculates required new lock duration to hit a desired unlock stamp.
219+
/// Reverts InvalidParam if unlockStamp is in the past or newLockAmount is zero.
195220
function calculateNewLockDuration(
196221
uint256 _unlockStamp,
197222
uint256 _remainingDuration,

0 commit comments

Comments
 (0)