Skip to content

Commit 9b08981

Browse files
committed
doc: update FlyoverDiscovery and IFlyoverDiscovery interfaces to inherit documentation
1 parent 5c28d34 commit 9b08981

2 files changed

Lines changed: 58 additions & 27 deletions

File tree

contracts/FlyoverDiscovery.sol

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,7 @@ contract FlyoverDiscovery is
4444
_collateralManagement = ICollateralManagement(collateralManagement);
4545
}
4646

47-
/// @notice Registers the caller as a Liquidity Provider
48-
/// @dev Reverts if caller is not an EOA, already resigned, provides invalid data, invalid type, or lacks collateral
49-
/// @param name Human-readable LP name
50-
/// @param apiBaseUrl Base URL of the LP public API
51-
/// @param status Initial status flag (enabled/disabled)
52-
/// @param providerType The service type(s) the LP offers
53-
/// @return id The newly assigned LP identifier
47+
/// @inheritdoc IFlyoverDiscovery
5448
function register(
5549
string calldata name,
5650
string calldata apiBaseUrl,
@@ -74,10 +68,7 @@ contract FlyoverDiscovery is
7468
return (lastProviderId);
7569
}
7670

77-
/// @notice Updates a provider status flag
78-
/// @dev Callable by the LP itself or the contract owner
79-
/// @param providerId The provider identifier
80-
/// @param status The new status value
71+
/// @inheritdoc IFlyoverDiscovery
8172
function setProviderStatus(
8273
uint providerId,
8374
bool status
@@ -89,10 +80,7 @@ contract FlyoverDiscovery is
8980
emit IFlyoverDiscovery.ProviderStatusSet(providerId, status);
9081
}
9182

92-
/// @notice Updates the caller LP metadata
93-
/// @dev Reverts if the caller is not registered or provides invalid fields
94-
/// @param name New LP name
95-
/// @param apiBaseUrl New LP API base URL
83+
/// @inheritdoc IFlyoverDiscovery
9684
function updateProvider(string calldata name, string calldata apiBaseUrl) external {
9785
if (bytes(name).length < 1 || bytes(apiBaseUrl).length < 1) revert InvalidProviderData(name, apiBaseUrl);
9886
Flyover.LiquidityProvider storage lp;
@@ -109,9 +97,7 @@ contract FlyoverDiscovery is
10997
revert Flyover.ProviderNotRegistered(providerAddress);
11098
}
11199

112-
/// @notice Lists LPs that should be visible to users
113-
/// @dev A provider is listed if it has sufficient collateral for at least one side and `status` is true
114-
/// @return providersToReturn Array of LP records to display
100+
/// @inheritdoc IFlyoverDiscovery
115101
function getProviders() external view returns (Flyover.LiquidityProvider[] memory) {
116102
uint count = 0;
117103
Flyover.LiquidityProvider storage lp;
@@ -132,17 +118,12 @@ contract FlyoverDiscovery is
132118
return providersToReturn;
133119
}
134120

135-
/// @notice Returns a single LP by address
136-
/// @param providerAddress The LP address
137-
/// @return provider LP record, reverts if not found
121+
/// @inheritdoc IFlyoverDiscovery
138122
function getProvider(address providerAddress) external view returns (Flyover.LiquidityProvider memory) {
139123
return _getProvider(providerAddress);
140124
}
141125

142-
/// @notice Checks if an LP can operate for peg-in side
143-
/// @dev Ignores the first argument as compatibility stub with legacy signature
144-
/// @param addr The LP address
145-
/// @return isOp True if registered and peg-in collateral >= min
126+
/// @inheritdoc IFlyoverDiscovery
146127
function isOperational(Flyover.ProviderType, address addr) external view returns (bool) {
147128
return _collateralManagement.isCollateralSufficient(Flyover.ProviderType.PegIn, addr) &&
148129
_getProvider(addr).status;
@@ -152,8 +133,7 @@ contract FlyoverDiscovery is
152133
// Getter Functions
153134
// ------------------------------------------------------------
154135

155-
/// @notice Returns the last assigned provider id
156-
/// @return lastId Last provider id
136+
/// @inheritdoc IFlyoverDiscovery
157137
function getProvidersId() external view returns (uint) {
158138
return lastProviderId;
159139
}
@@ -162,6 +142,11 @@ contract FlyoverDiscovery is
162142
// FlyoverDiscovery Private Functions
163143
// ------------------------------------------------------------
164144

145+
/// @notice Adds collateral to the collateral management contract based on provider type
146+
/// @dev Distributes collateral between peg-in and peg-out based on provider type
147+
/// @param providerType The type of provider (PegIn, PegOut, or Both)
148+
/// @param providerAddress The address of the provider
149+
/// @param collateralAmount The total amount of collateral to add
165150
function _addCollateral(
166151
Flyover.ProviderType providerType,
167152
address providerAddress,
@@ -179,10 +164,21 @@ contract FlyoverDiscovery is
179164
}
180165
}
181166

167+
/// @notice Checks if a liquidity provider should be listed in the public provider list
168+
/// @dev A provider is listed if it is registered and has status enabled
169+
/// @param lp The liquidity provider storage reference
170+
/// @return True if the provider should be listed, false otherwise
182171
function _shouldBeListed(Flyover.LiquidityProvider storage lp) private view returns(bool){
183172
return _collateralManagement.isRegistered(lp.providerType, lp.providerAddress) && lp.status;
184173
}
185174

175+
/// @notice Validates registration parameters and requirements
176+
/// @dev Checks EOA status, data validity, provider type, registration status, and collateral requirements
177+
/// @param name The provider name to validate
178+
/// @param apiBaseUrl The provider API URL to validate
179+
/// @param providerType The provider type to validate
180+
/// @param providerAddress The provider address to validate
181+
/// @param collateralAmount The collateral amount to validate against minimum requirements
186182
function _validateRegistration(
187183
string memory name,
188184
string memory apiBaseUrl,
@@ -222,6 +218,10 @@ contract FlyoverDiscovery is
222218
}
223219
}
224220

221+
/// @notice Retrieves a liquidity provider by address
222+
/// @dev Searches through all registered providers to find a match
223+
/// @param providerAddress The address of the provider to find
224+
/// @return The liquidity provider record, reverts if not found
225225
function _getProvider(address providerAddress) private view returns (Flyover.LiquidityProvider memory) {
226226
for (uint i = 1; i < lastProviderId + 1; ++i) {
227227
if (_liquidityProviders[i].providerAddress == providerAddress) {

contracts/interfaces/IFlyoverDiscovery.sol

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,50 @@ interface IFlyoverDiscovery {
1515
error AlreadyRegistered(address from);
1616
error InsufficientCollateral(uint amount);
1717

18+
/// @notice Registers the caller as a Liquidity Provider
19+
/// @dev Reverts if caller is not an EOA, already resigned, provides invalid data, invalid type, or lacks collateral
20+
/// @param name Human-readable LP name
21+
/// @param apiBaseUrl Base URL of the LP public API
22+
/// @param status Initial status flag (enabled/disabled)
23+
/// @param providerType The service type(s) the LP offers
24+
/// @return id The newly assigned LP identifier
1825
function register(
1926
string calldata name,
2027
string calldata apiBaseUrl,
2128
bool status,
2229
Flyover.ProviderType providerType
2330
) external payable returns (uint);
2431

32+
/// @notice Updates the caller LP metadata
33+
/// @dev Reverts if the caller is not registered or provides invalid fields
34+
/// @param name New LP name
35+
/// @param apiBaseUrl New LP API base URL
2536
function updateProvider(string calldata name, string calldata apiBaseUrl) external;
37+
38+
/// @notice Updates a provider status flag
39+
/// @dev Callable by the LP itself or the contract owner
40+
/// @param providerId The provider identifier
41+
/// @param status The new status value
2642
function setProviderStatus(uint providerId, bool status) external;
2743

44+
/// @notice Lists LPs that should be visible to users
45+
/// @dev A provider is listed if it has sufficient collateral for at least one side and `status` is true
46+
/// @return providersToReturn Array of LP records to display
2847
function getProviders() external view returns (Flyover.LiquidityProvider[] memory);
48+
49+
/// @notice Returns a single LP by address
50+
/// @param providerAddress The LP address
51+
/// @return provider LP record, reverts if not found
2952
function getProvider(address providerAddress) external view returns (Flyover.LiquidityProvider memory);
53+
54+
/// @notice Checks if an LP can operate for peg-in side
55+
/// @dev Ignores the first argument as compatibility stub with legacy signature
56+
/// @param providerType The provider type (ignored for compatibility)
57+
/// @param addr The LP address
58+
/// @return isOp True if registered and peg-in collateral >= min
3059
function isOperational(Flyover.ProviderType providerType, address addr) external view returns (bool);
3160

61+
/// @notice Returns the last assigned provider id
62+
/// @return lastId Last provider id
3263
function getProvidersId() external view returns (uint);
3364
}

0 commit comments

Comments
 (0)