You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds validation for critical constructor/config parameters in FlowYieldVaultsRequests to avoid misconfiguration at deploy time and prevent zero-minimum supported tokens.
Key points:
Constructor now reverts if coaAddress == address(0)
Introduced InvalidMinimumBalance for invalid supported-token minimums
Token configuration now enforces minimumBalance > 0 when isSupported == true
Constructor token setup and admin token updates share one internal validation path (_setTokenConfig)
Changes:
Added constructor guard for zero COA address
Added internal _setTokenConfig(...) helper with validation
Updated constructor + setTokenConfig(...) to use shared helper
Added tests for constructor zero-COA revert and zero-minimum supported-token revert
Test plan
FOUNDRY_OFFLINE=true forge test --match-contract FlowYieldVaultsRequestsTest
Overall: This is a clean, well-scoped improvement. The changes are correct, follow existing patterns in the codebase (reusing InvalidCOAAddress, which already guards setAuthorizedCOA), and the tests cover the new validation paths. A few minor observations below.
Strengths
DRY: Extracting the duplicate struct assignment into _setTokenConfig removes two identical code blocks and ensures constructor and admin paths share a single validation path — exactly the right pattern.
Named constant: DEFAULT_MINIMUM_BALANCE = 1 ether removes the magic 1 ether literals. Good.
Guard reuse: Reusing the pre-existing InvalidCOAAddress error in the constructor is consistent with setAuthorizedCOA.
Validation condition: if (isSupported && minimumBalance == 0) correctly allows minimumBalance = 0 when disabling a token (isSupported = false), which is the right semantics.
Issues / Observations
1. Missing tokenAddress zero-address check in _setTokenConfig (pre-existing gap, but now is the natural moment to fix)
_setTokenConfig doesn't validate tokenAddress != address(0). An admin could call setTokenConfig(address(0), true, 1 ether, false), inadvertently configuring the zero address as a supported token. The constructor is safe because it only calls this with NATIVE_FLOW and WFLOW, but the external setTokenConfig path is open. Consider adding:
if (tokenAddress ==address(0)) revertInvalidTokenAddress(); // or reuse a suitable existing error
2. setTokenConfig emits event but constructor doesn't — minor inconsistency
setTokenConfig calls _setTokenConfig then emits TokenConfigured. The constructor also calls _setTokenConfig for NATIVE_FLOW (and optionally WFLOW) but emits nothing. This was the same before this PR, but since _setTokenConfig is now a shared path it's worth noting: the constructor-time token configuration is silent on-chain. For a deploy-and-monitor workflow this is fine, but indexers/subgraphs that rely on TokenConfigured events won't see the initial state.
3. Redundant > 0 check in _validateDeposit (minor)
_validateDeposit at line ~1475 guards with if (config.minimumBalance > 0 && ...). With this PR's invariant that all supported tokens must have minimumBalance > 0, the > 0 half of that condition is now always true for supported tokens. Not a bug — it's defensive — but worth noting as dead logic.
4. Missing test coverage
isSupported = false, minimumBalance = 0 (valid disable path): The new tests cover the revert paths, but there's no test asserting that setTokenConfig(token, false, 0, false) succeeds (the boundary case the condition is designed to allow).
Constructor default state: No test verifies that after construction allowedTokens[NATIVE_FLOW].minimumBalance == DEFAULT_MINIMUM_BALANCE. Given the constant was introduced specifically for this, a snapshot test would lock in that behavior.
Constructor with wflowAddress == address(0): No test confirms WFLOW is not configured when zero address is passed.
Summary
The core changes are correct and well-structured. Items 1 (zero-address token guard) and 4 (missing test cases) are the most actionable. Everything else is informational. Happy to approve once the token-address guard question is addressed or explicitly dismissed as out of scope.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #34
Adds validation for critical constructor/config parameters in
FlowYieldVaultsRequeststo avoid misconfiguration at deploy time and prevent zero-minimum supported tokens.Key points:
coaAddress == address(0)InvalidMinimumBalancefor invalid supported-token minimumsminimumBalance > 0whenisSupported == true_setTokenConfig)Changes:
_setTokenConfig(...)helper with validationsetTokenConfig(...)to use shared helperTest plan
FOUNDRY_OFFLINE=true forge test --match-contract FlowYieldVaultsRequestsTest