Skip to content

Commit ff56174

Browse files
committed
Style: improve code readability and correct loop boundaries into strict
1 parent baa474e commit ff56174

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

contracts/FlyoverDiscovery.sol

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,16 @@ contract FlyoverDiscovery is
8585

8686
/// @notice Resigns the caller as a Liquidity Provider
8787
/// @dev Reverts if the caller is not registered or already resigned
88-
/// @dev Resignation is permanent and cannot be undone. To recover the collateral, the liquidity provider must go through the resignation process, if that happens and the same account wishes to register again, that would result in a different provider ID.
88+
/// @dev Resignation is permanent and cannot be undone. To recover the collateral, the liquidity provider must go
89+
/// through the resignation process, if that happens and the same account wishes to register again, that would
90+
/// result in a different provider ID.
8991
function resign() external override {
9092
address providerAddress = msg.sender;
91-
if (_resignationBlockNum[providerAddress] != 0) revert AlreadyResigned(providerAddress);
93+
if (_resignationBlockNum[providerAddress] != 0)
94+
revert AlreadyResigned(providerAddress);
9295
if (
93-
_collateralManagement.getPegInCollateral(providerAddress) <= 0 &&
94-
_collateralManagement.getPegOutCollateral(providerAddress) <= 0
96+
_collateralManagement.getPegInCollateral(providerAddress) < 1 &&
97+
_collateralManagement.getPegOutCollateral(providerAddress) < 1
9598
) {
9699
revert Flyover.ProviderNotRegistered(providerAddress);
97100
}
@@ -122,7 +125,7 @@ contract FlyoverDiscovery is
122125
if (bytes(name).length < 1 || bytes(apiBaseUrl).length < 1) revert InvalidProviderData(name, apiBaseUrl);
123126
Flyover.LiquidityProvider storage lp;
124127
address providerAddress = msg.sender;
125-
for (uint i = 1; i <= lastProviderId; ++i) {
128+
for (uint i = 1; i < lastProviderId + 1; ++i) {
126129
lp = _liquidityProviders[i];
127130
if (providerAddress == lp.providerAddress) {
128131
lp.name = name;
@@ -147,14 +150,14 @@ contract FlyoverDiscovery is
147150
function getProviders() external view returns (Flyover.LiquidityProvider[] memory) {
148151
uint count = 0;
149152
Flyover.LiquidityProvider storage lp;
150-
for (uint i = 1; i <= lastProviderId; ++i) {
153+
for (uint i = 1; i < lastProviderId + 1; ++i) {
151154
if (_shouldBeListed(_liquidityProviders[i])) {
152155
++count;
153156
}
154157
}
155158
Flyover.LiquidityProvider[] memory providersToReturn = new Flyover.LiquidityProvider[](count);
156159
count = 0;
157-
for (uint i = 1; i <= lastProviderId; ++i) {
160+
for (uint i = 1; i < lastProviderId + 1; ++i) {
158161
lp = _liquidityProviders[i];
159162
if (_shouldBeListed(lp)) {
160163
providersToReturn[count] = lp;
@@ -247,7 +250,7 @@ contract FlyoverDiscovery is
247250
}
248251

249252
function _getProvider(address providerAddress) private view returns (Flyover.LiquidityProvider memory) {
250-
for (uint i = 1; i <= lastProviderId; ++i) {
253+
for (uint i = 1; i < lastProviderId + 1; ++i) {
251254
if (_liquidityProviders[i].providerAddress == providerAddress) {
252255
return _liquidityProviders[i];
253256
}

0 commit comments

Comments
 (0)